Firefox and defer="defer"

  • Written by: Marko Samastur
  • Published on:
  • Category: General development, Web

If you’re sitting in the wrong part of the world, then Google might be inaccessible to you right now. That would be only a minor annoyance, if the same wasn’t true also for Google Analytics.

It’s remarkable how many sites (including this one) use it and are right now more or less inaccessible to every poor soul suffering from Google blackout. That’s because browser can’t tell if external Javascript will use a method like document.write and therefore blocks rendering until the code is loaded or it timeouts waiting for it.

There should be a workaround for times like this and according to HTML4 specification there is one . By using defer=”defer” we can signal to the browser that it can safely proceed rendering the page, because we won’t be using any dangerous methods in our Javascript files.

However, it sadly doesn’t work everywhere. It works in Internet Explorer, but fails in Firefox and Safari. And that simply sucks.