In order to shorten the time to open the page,
I'm thinking of load part of the scripts after the page is loaded.
The standard is to append new scripts into <head>
part,right?
In order to shorten the time to open the page,
I'm thinking of load part of the scripts after the page is loaded.
The standard is to append new scripts into <head>
part,right?
Just put your scripts at the end of the <body>
, that way everything before will load first.
To add to that point, if you are going to place all script tags at the bottom, and you are using some javascript libraries. Please be careful in handling your javascript embedded in your html, with onclick, onchange.. options. they might start to throw errors.
Trying to keep javascript as unobtrusive as possible is the key to make this above method work.
If you don't want to put it at the end of body, as suggested, you might to take a look at jQuery.getScript(url, callback)
In general I would suggest putting your own scripts in the head and external scripts just before </body>
, for a few reasons:
Some user agents understand the defer="true" attribute on the element.