Home

(Java)script defer

I have noticed that when my blog loads, there’s a pause while the browser hits the server to download my DHTML scripts.  Since most of the scripts respond to user interaction and don’t need to be there as the page is rendering, that seemed like a pretty big waste of loading time.  So I was tickled some colour of pink (possible purple) when I found the "defer" attribute today.  Using <script defer>, "the user agent can continue parsing and rendering" without downloading the javascript.  It might not change the world overnight, but it can’t hurt…or can it?  Woohoohoo *evil laugh*  Almost certainly not :|

Scripts in HTML documents

When set, this boolean attribute provides a hint to the user agent that the script is not going to generate any document content (e.g., no "document.write" in javascript) and thus, the user agent can continue parsing and rendering.

 

Related Posts

5 Responses to “(Java)script defer”

  1. Daniel F says:

    Nice!

    [yes, not the worlds biggest comment :) ]

  2. Daniel F says:

    Probably not the right spot to tell you about it, but I can’t find an email addy for you anywhere…

    Your site no longer works on IE for me :(
    It appears to do a redirect to c7.staticcounter.com and doesn’t come back. Could this be related to the new defer you’ve whacked in your javascripts? It works fine and dandy in Moz still. Not such a bad way to keep IE users out :D

  3. Jonathan says:

    Yes…I meant to do that…totally planned like you said… :D

    I forgot that the invisible GIF from the StatCounter probably would require its Javascript include. Doh! Thanks for the heads up. I have nothing specific against the IE people, misguided as they might be :-)

  4. Daniel F says:

    Shibby! Back in action again.

    I’d make up all sorts of exotic excuses as to why I run IE as my default, but they’d all be bollocks. Really, I’m too lazy to make the switch to firefox permanently :)

  5. Jonathan says:

    Once you install some extensions in Firefox, you’ll never be able to live without them again ;-) Mouse gestures are like crack to me :D