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:

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


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.