Forum Moderators: open

Message Too Old, No Replies

Running a script as soon as possible

         

ocon

10:43 am on Apr 1, 2015 (gmt 0)

10+ Year Member Top Contributors Of The Month



Where do I place a script to run as soon as possible? Is it possible to run a script before the page is even fully downloaded?

Currently I have no external requests (scripts or otherwise) and all my functions and calls are in one script tag at the end of the document right before </body> (this is the best place for them, right?). If I have one autonomous script that I want to run ASAP is the best place for it in the head?

Fotiman

12:53 pm on Apr 1, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes, putting it in the head is the best place in that case. For example, Modernizr [modernizr.com] should go in the <head>, but generally speaking the rest of your scripts are best placed just before the closing </body>.