Remember to “defer” your scripts when possible

The HTML 4 specification defined the defer attribute for the element and many browsers now support it.  The beauty of this little attribute is if your script block does not actually modify the DOM then you should consider using this because it will download and execute your script once the page is fully loaded.  This will give the perception to the page viewer that the page is complete with no hourglass or white screen.  If your scripts do modify the DOM you might want to consider putting  a

block with an id and then replace that id with the content from within the script- this will allow your script to be executed after the page is loaded.  For instance:

defer>
--code to modify the "myId" div content --

			

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s