Boomerang Howto #4: Measure more than just page load time

Up until now we've measured the time it takes for a page to become usable by the user. It may also be
useful to measure the time it took for various components within the page to load and match that up with
the full page load time. boomerang provides additional timers that you can configure to measure separate
parts of your page. You use the startTimer() and endTimer() methods of the
roundtrip (BOOMR.plugin.RT) plugin to do this.

In the following examples, you'll need to make sure that boomerang.js is loaded and the
init() method called before you call any of these methods, so perhaps putting it at the
top of your page is a good idea. We'll see later how to work around this.

First, identify sections of your page that you want to measure. Call startTimer() before
and endTimer() after. Each timer has its own name. The names are free-form strings,
but stay simple to be efficient. Stick to alphanumeric characters and underscores, and limit names
to around 5 characters, eg: t_ads, t_head, t_js. The following
names are reserved: t_done, t_page, t_resp.

Notice in the second invocation how we chain the calls to endTimer and startTimer.
This is possible for most methods that you call since they return a reference to the object. Note
that the timer methods are run on the BOOMR.plugins.RT object, so they return a reference
to that object and not to the BOOMR object.

Measuring time for content loaded before boomerang

Now we've said for years that putting javascript at the bottom of your document is good for
performance, so asking you to load boomerang at the top may not be the best advice. You can
still measure in-page times though, and then report them to boomerang once it has loaded.
You do this using the BOOMR.plugins.RT.setTimer() method. This method takes
two parameters — the timer name and its value in milliseconds. The code above will
change to this: