BOOMR.plugins. ResourceTiming

Plugin to collect metrics from the W3C ResourceTiming API.

For information on how to include this plugin, see the Building tutorial.

Beacon Parameters

This plugin adds the following parameters to the beacon for Page Loads:

  • restiming: Compressed ResourceTiming data

The ResourceTiming plugin adds an object named restiming to the beacon data.

restiming is an optimized Trie structure, where the keys are the ResourceTiming URLs, and the values correspond to those URLs' PerformanceResourceTiming timestamps:

{ "[url]": "[data]"}

The Trie structure is used to minimize the data transmitted from the ResourceTimings.

Keys in the Trie are the ResourceTiming URLs. For example, with a root page and three resources:

  • (downloaded twice)

Then the Trie might look like this:

// Example 1
    "|": "0,2",
    "js/foo.js": "3a,1",
    "css/": {
      "foo.css": "2b,2",
      "foo.png": "1c,3|1d,a"

If a resource's URL is a prefix of another resource, then it terminates with a pipe symbol (|). In Example 1, (the root page) is a prefix of, so it is listed as| in the Trie.

If there is more than one ResourceTiming entry for a URL, each entry is separated by a pipe symbol (|) in the data. In Example 1 above, foo.png has been downloaded twice, so it is listed with two separate page loads, 1c,3 and 1d,a.

The value of each key is a string, which contains the following components:

data = "[initiatorType][timings]"

initiatorType is a simple map from the PerformanceResourceTiming initiatorType (which is a string) to an integer, according to the BOOMR.plugins.ResourceTiming.INITAITOR_TYPES enum.

timings is a string of Base-36 encoded timestamps from the PerformanceResourceTiming interface. The values in the string are separated by commas:

timings = "[startTime],[responseEnd],[responseStart],[requestStart],[connectEnd],[secureConnectionStart],[connectStart],[domainLookupEnd],[domainLookupStart],[redirectEnd],[redirectStart]"

startTime is a DOMHighResTimeStamp from when the resource started (Base 36).

All other timestamps are offsets (rounded to milliseconds) from startTime (Base 36). For example, responseEnd is calculated as:

responseEnd: base36(round(responseEnd - startTime))

If the resulting timestamp is 0, it is replaced with an empty string ("").

All trailing commas are removed from the final string. This compresses the timing string from timestamps that are often 0. For example, here is what a fully-redirected resource might look like:

{ "": "01,1,1,1,1,1,1,1,1,1,1" }

While a resource that was loaded from the cache (and thus only has startTime and responseEnd timestamps) might look like this:

{ "": "01,1" }

Note that some of the metrics are restricted and will not be provided cross-origin unless the Timing-Allow-Origin header permits.

Putting this all together, let's look at in Example 1. We find it was downloaded twice "1c,3|1d,a":

  • 1c,3:
    • 1: initiatorType = 1 (IMG)
    • c: startTime = c (12ms)
    • 3: responseEnd = 3 (3ms from startTime, or at 15ms)
  • 1d,a:
    • 1: initiatorType = 1 (IMG)
    • d: startTime = d (13ms)
    • 2: responseEnd = a (10ms from startTime, or at 23ms)





  • number


Name Type Default Description
other number 0

Unknown type

img number 1

IMG element

link number 2

LINK element (i.e. CSS)

script number 3

SCRIPT element

css number 4

Resource referenced in CSS

xmlhttprequest number 5


html number 6

The root HTML page itself

image number 7

IMAGE element inside a SVG

beacon number 8


fetch number 9

Fetch API

iframe number a


subdocument number a

IE11 and Edge (some versions) send "subdocument" instead of "iframe"

REL_TYPES :number

These are the only rel types that might be reference-able from ResourceTiming.


  • number


Name Type Default Description
prefetch number 1
preload number 2
prerender number 3
stylesheet number 4


addResourceTimingToBeacon( [number] [, number])

Adds 'restiming' and 'servertiming' to the beacon


Name Type Argument Description
number <optional>

from Only get timings from

number <optional>

to Only get timings up to

calculateResourceTimingUnion( [ResourceTiming[]])

Calculates the union of durations of the specified resources. If any resources overlap, those timeslices are not double-counted.


Name Type Argument Description
ResourceTiming[] <optional>

resources Resources


Duration, in milliseconds

getCompressedResourceTiming( [number] [, number])

Gathers performance entries and compresses the result.


Name Type Argument Description
number <optional>

from Only get timings from

number <optional>

to Only get timings up to


An object containing the Optimized performance entries trie and the optimized server timing lookup

getFilteredResourceTiming(from, to, initiatorTypes)

Gathers a filtered list of performance entries.


Name Type Description
from number

Only get timings from

to number

Only get timings up to

initiatorTypes Array.<string>

Array of initiator types


Type: Array.<ResourceTiming>

Matching ResourceTiming entries


Initializes the plugin.


Name Type Description
config object


Name Type Argument Description
ResourceTiming.xssBreakWorks Array.<string> <optional>

Words that will be broken (by ensuring the optimized trie doesn't contain the whole string) in URLs, to ensure NoScript doesn't think this is an XSS attack.


ResourceTiming.clearOnBeacon boolean <optional>

Whether or not to clear ResourceTiming data on each beacon.

ResourceTiming.urlLimit number <optional>

URL length limit, after which ... will be used

ResourceTiming.trimUrls Array.<string> | Array.<RegExp> <optional>

List of strings of RegExps to trim from URLs.


BOOMR.plugins.ResourceTiming The ResourceTiming plugin for chaining


Whether or not this plugin is complete


Type: boolean

true if the plugin is complete


Whether or not this ResourceTiming is enabled and supported.


Type: boolean

true if ResourceTiming plugin is enabled.


Whether or not ResourceTiming is supported in this browser.


Type: boolean

true if ResourceTiming is supported.