« Return to Thread: Javascript at the end of a page

Re: Javascript at the end of a page

by Richard Hart :: Rate this Message:

Reply to Author | View in Thread

Sadly this doesn't answer your question, but personally I think if it takes 10seconds for the server to return a simple JS file (as in that example) of only a few hundred KB, then the impact on your pages loading time is the least of a web developers worries. I say, just include them at the top of your page. If they are large, then look into compressing or packing them. You can get JS filesizes down to tiny sizes using those techniques. After which the loading time impact will be negligible.

If you need to run some code, which is blocking for longer then you'd like, then use something like jQuery to run the code once the page has finished rendering:

$(document).ready {
   // Call your function here.
}

 « Return to Thread: Javascript at the end of a page