Interesting podcast by Scott Hanselman and Nicholas Zakas:

http://hanselminutes.com/383/enough-with-the-javascript-already-with-nicholas-zakas

 

It mentions the 4 JavaScript load opportunities:

  1. In the <head> tag
  2. Before the </body> tag
  3. After page load (windows.onload DOM ready function)
  4. On demand (when user clicks a button, mouse is 100px from button, user types first letter etc.)

 

For performance reasons, use 4, then 3, then 2 and if you can’t do without, use 1.

Leave a Reply

Your email address will not be published. Required fields are marked *

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