Comments for High Performance Web Sites Essential knowledge for making your web pages faster. Tue, 21 Oct 2014 11:41:32 +0000 hourly 1 Comment on Onload in Onload by Saikat Tue, 21 Oct 2014 11:41:32 +0000 I don’t know how good it is but can’t we fire another onload event i.e so that the second window onload function gets fired by the fake load event. like this


var evt = document.createEvent(‘Event’);
evt.initEvent(‘load’, false, false);
//so both alerts are shown

Comment on do u webview? by Daniel Fri, 17 Oct 2014 07:36:57 +0000 A lot of this is pretty relevant to a project we’re on the edge of completing now.

We’ve discovered and overcome a lot of nuances and quirks with webviews on both iOS and Android so this is a great reference to start writing up some of the lessons we learned.

I’m especially excited about the V8 going in there for the new webviews!

Thanks for this post!

Comment on Onload in Onload by Laurens van Hees Mon, 13 Oct 2014 06:34:57 +0000 Another tip, when the Navigation Timing API is available you can do something like this as well:

var isLoadFired = window.performance.timing.loadEventStart > 0;

Comment on Resource Timing practical tips by Radko Dinev Fri, 03 Oct 2014 10:13:20 +0000 Firefox supports the Resource Timing API since version 31 behind the `dom.enable_resource_timing` preference flag which is `false` by default.

Comment on Onload in Onload by Steve Souders Fri, 26 Sep 2014 19:34:09 +0000 It’s more overhead to have a timer looping like that.

Comment on Onload in Onload by Allen Lee Fri, 26 Sep 2014 19:01:01 +0000 Great post.

So why not use document.readyState directly and skip onload and addEventListener entirely? IE

var f = function() { …. };

function fAfterLoad() {
if (document.readyState == “complete”) f();
else window.setTimeout(fAfterLoad, 250)


The use case is a third party snippet for analytics that should be transparent to the user, i.e. google analytics. This has the advantage of being compatible with all browsers without special hacks for IE8 and not over writing window.onload, which could be used by the page.

Comment on Onload in Onload by Steve Souders Wed, 17 Sep 2014 15:45:09 +0000 Philip: I tested Boomerang while writing this post and was pleased to see it used readyState to avoid this problem. You’re always one step ahead.

Comment on Onload in Onload by Philip Tellis (@bluesmoon) Wed, 17 Sep 2014 13:48:48 +0000 Hi Steve,

The addEventListener spec states that if an event handler is added via code that runs as part of that event, then the new handler will only be called on subsequent invocations of the event. Since onload can only fire once, this means that onload handlers added in onload will never be called (assuming browsers follow the spec for this).

I noticed this when we started loading boomerang using the iframe loader technique, since there was now a possibility that it could load after onload (and well, some of our customers load boomerang in the onload event). As a result, boomerang has been using document.readyState for a while now to check if onload has already fired when it loads up.

Comment on Resource Timing practical tips by Brian Nørremark Sat, 30 Aug 2014 17:10:10 +0000 Steve: Any beaconing packages you can recommend? I don’t think Boomerang splits up into multiple beacons.

An idea for a more robust data could be to capture aggregated data, like the ones that HTTPArchive tracks. response sizes is not possible, but you could easily aggregate: # JS/CSS/GIF/PNG/JPG/HTML/Fonts/Flash/Other requests, # HTTPS requests, # iframes, and probaly a few more.
The more I think about it, the more I like the idea. Correlations makes it all worth it, even though SPDY may change the picture quite a lot.

Comment on Resource Timing practical tips by Steve Souders Fri, 29 Aug 2014 16:50:21 +0000 Brian: Some beaconing packages track the querystring length and break it across multiple beacons when necessary. Doing a POST is also possible. I agree – sending back Resource Timing data for every resource in the page is likely to exceed URL length. FYI – Eric Lawrence just blogged about this in URL Length Limits.