Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enqueuing scripts in header #14

Closed
garybrowne opened this issue Aug 7, 2014 · 3 comments
Closed

Enqueuing scripts in header #14

garybrowne opened this issue Aug 7, 2014 · 3 comments
Labels

Comments

@garybrowne
Copy link

Hi there,
Just wondering if there is a specific reason that you enqueue all the scripts in the header rather than the footer?
Thanks,
Gary

@ProjectCleverWeb
Copy link
Owner

Scripts loaded in the head are downloaded asynchronously of each other before the page loads, while scripts in the footer are downloaded in sequence after the rest of the page is loaded. The difference is that when you load in the head, your net page load time is faster.

The only good time to load scripts in the footer, is when you have a very JavaScript heavy website, and loading in footer makes the page appear noticeably faster. (I would say at least 250ms faster)

Otherwise, it makes more sense to load them in the head. In this case, most servers will serve the files up fast enough that you won't be able to tell the difference.


P.S.

You can cut about 200 or so milliseconds off page load time by combining all the JS files into one and just serving that 1 file. This is due to the protocol for the server & client connection. You can achieve a similar effect without combining files by implementing SPDY

@garybrowne
Copy link
Author

Thanks Nicholas!

@ProjectCleverWeb
Copy link
Owner

No problem, and glad I could help 😃

Also, to extend my note on combining files and then serving them. The amount of the decrease in page load time varies from server-to-server, and is largely dependent on how Apache/PHP is configured to work on the system and where the server is located. For example, on a slower configuration, this may save you 400ms and on a faster and distributed system this may only save you 100ms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants