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

Re: Javascript at the end of a page

by Burt Beckwith :: Rate this Message:

Reply to Author | View in Thread

The problem isn't that the files are huge and take a long time to download -
it's that the script is evaluated as it's loaded, and if that isn't necessary
at that point in the page (i.e. if there's no document.write statements) then
it's best to let that 10 seconds happen after the page is visible in the
browser rather than holding up the display unnecessarily.

It's all about perceived page load time.

Burt

On Tuesday 12 August 2008 7:33:16 pm Hates_ wrote:

> 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.
> }



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


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