Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>According to W3C you could put scripts almost anywhere: <a href="http://www.w3schools.com/js/js_whereto.asp" rel="nofollow">http://www.w3schools.com/js/js_whereto.asp</a></p> <p>So where should you put them?</p> <p>Ege is right to say that you should put them as far down the page as possible because it will enable the browser to load more in parallel up front before it gets to the 'blocking' scripts. See here for more detail: <a href="http://developer.yahoo.com/performance/rules.html#js_bottom" rel="nofollow">http://developer.yahoo.com/performance/rules.html#js_bottom</a></p> <p>Also, it is nearly always a good idea to put your scripts (and CSS) into external files so the browser can cache them tus saving the user from having to download them with the page each time.</p> <p>Personally, I always use a CDN for script frameworks such as jQuery and the like as they can deliver external resources quicker than you probably can. Also the likelyhood of the browser having already cached jQuery for another site from the same CDN is far more likely. More detail here: <a href="http://code.google.com/apis/libraries/devguide.html" rel="nofollow">http://code.google.com/apis/libraries/devguide.html</a></p> <p>Finally, there's nothing wrong with using $(document).ready, but just be aware that this could affect the site's responsiveness and its pros may not outweight its cons. Again, more detail here: <a href="http://encosia.com/2010/08/18/dont-let-jquerys-document-ready-slow-you-down/" rel="nofollow">http://encosia.com/2010/08/18/dont-let-jquerys-document-ready-slow-you-down/</a></p> <p>Hope this helped.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload