Reputation: 547
We are developing a master dynamic web template for our users. There are certain pages that may require calls to jquery-1.11.3.min.js for some functionality. The question came up about including it in the master page so it is available on every page if needed. I am curious if there is a performance or security penalty for doing this.
Upvotes: 1
Views: 84
Reputation: 25402
The best answer here is really an opinion: your opinion.
This kind of thing is not necessarily bad practice; however, it can cause your website to slow down if the viewer has not cached the particular version of jQuery that you are using.
The answer to your question is another question: are you willing to make that sacrifice in order to be lazy and not include the link in every page that requires jQuery?
Upvotes: 0
Reputation: 325
The first time it is requested, there may be a hit.
However, because jQuery is used widely, the chances are that it will be cached at some point along the server request chain, and quite possibly in the user's browers anyway. It's also minified, so the size is quite small.
That said, even if not cached, once it's been requested once, it will be cached in the users browser (almost certainly).
Here are some interesting questions / articles for further reading / info: Yahoo is well known for contributing to general knowledge on speeding up websites - read about this here: http://developer.yahoo.com/performance/rules.html
Google's equivalent: https://developers.google.com/speed/docs/insights/rules
Upvotes: 0
Reputation: 89725
It's considered a bad practice to include files that are unused. Even though they might be cached, they still take up memory. If they are not cached then extra connection and trips are made over the wire and slow down your page.
I would recommend to use RequireJS for all your javascript dependency resolution
Upvotes: 1