Mobile app version of vmapp.org
Login or Join
Barnes591

: Why don't browsers have jQuery installed? I'm using jQuery on several of my websites and although I use a CDN to serve it, it just doesn't make sense for visitor to download jQuery each time.

@Barnes591

Posted in: #Browsers #Cache #Jquery

I'm using jQuery on several of my websites and although I use a CDN to serve it, it just doesn't make sense for visitor to download jQuery each time. jQuery must be the world's most widely used JavaScript framework - wouldn't it make more sense if browsers just have it installed by default?

In that way millions of times a day a download of jQuery could be prevented. Either from people's own websites or from the CDNs.

All that would be really needed is some kind of if statement like:

<!--[if jQuery gt 11]>


Does something exist that will help me prevent users making the trip to the CDN if they already have jQuery in their cache from another site?

10.05% popularity Vote Up Vote Down


Login to follow query

More posts by @Barnes591

5 Comments

Sorted by latest first Latest Oldest Best

 

@Martha676

I actually think the responders on here fail to understand that the answer to the question is browsers probably should look to include the most widely used libraries, and polyfills etc on the client side.

As the person asking the question states, conditional comments could be used to ensure that those using browsers that don't include jquery were served an appropriate version.

Jquery also includes it's own backwards compatibility support through migrate, allowing for conditional comments to give retro support for someone with a packaged version of an older jquery library without downloading a whole new library.

The argument FOR including these in browsers would be not just about user experience and cost, but also about this planet we live on. The use of data is a huge contribution to global pollution, and ensuring that needless data transfer is minimised could have a dramatic effect on our carbon footprint.

In essence for the sake of adding an additional few megabytes of code bloat in a packaged browser - the same data is being needlessly ferried about billions of times a day.

That worsens user experience for everyone on the internet. And costs major businesses huge amounts of money.

As a developer you would just create the necessary fallbacks required as we do currently for IE etc, so what's the problem - it probably should be included surely?

10% popularity Vote Up Vote Down


 

@Correia994

A reason for using a library like jQuery is compatibility.

Browsers have become more standard-complying, but by using the jquery library, you supply yourself, you don't have to worry about differences between browser families and versions

By supplying the jquery yourself, you are sure to have a consistent api.

If we have the jquery built into the browser, you have to check which version the user have, and we are back into the browsersniffing and "This site is best viewed in ..."

So having the jquery build into the browser does not make sense.

Also, caching works, so even if the user does not already have your jquery version, it only needs to be downloaded once.

10% popularity Vote Up Vote Down


 

@Jennifer507

The browser is the engine it isn't the engine designer's duty to find out what kind of fuel and extra parts are you going to put into your car and include it for you. If they would do this browsers would be a huge bloatware because the next question will be "why just jQuery?", and we would end up maintaining dependency repositories.

Also, will we include all versions? What if somebody would like to use a custom version? What if somebody wouldn't like to use that library? How often they will merge and roll the latest releases? Will we end up with different browsers with different versioned jQuerys? They can't even equally implement standardised HTML, CSS and JavaScript functionalities. What if one of the browser maintainers aren't going to include a library or its specific version?

Browsers provide building blocks and an environment for you to build not an already finished solution.

Putting jQuery into the browser isn't going to make your site load blazingly fast because in nowadays this isn't the biggest bottleneck, however we can agree that jQuery is a needlessly big library but its purpose was never to be a fast library (considering bandwidth). There are many other libraries that were specifically designed around fast loading and to be lightweight like Zepto.

If you really that concerned about jQuery's size and bandwidth usage, then don't use it. Have you ever heard about Vanilla JS? It is an even more popular library that is used literally by almost everybody including jQuery itself! And it already fulfilled your dream because it is included in every browser!

10% popularity Vote Up Vote Down


 

@Karen161

Not only is jQuery not the only popular JS library, a browser would potentially have to include multiple versions. The Google CDN currently lists: 42 versions of jQuery; 44 versions of jQuery UI; 6 versions of jQuery Mobile.

It's better to allow web developers to define which version of a library to download based on their website's requirements. If you use a current production version of jQuery on your website and load it from a more popular CDN, then there's a good chance your visitors will already have it cached anyway.

10% popularity Vote Up Vote Down


 

@Harper822

If you serve jQuery from a popular CDN such as Google's Hosted Libraries or cdnjs, it won't be redownloaded if your visitor has been on a site that referenced it from the same source (as long as the cached version has not expired).

jQuery is a popular library, just as you say, but bundling it with the browser is not likely to happen for a few reasons:


jQuery is relatively small (compared to libraries that are sometimes bundled in browsers, like Flash). The largest performance bottlenecks on the average site are unlikely to be due to downloading jQuery.
Improvements to JavaScript/ECMAScript mean that developers are increasingly not required to depend on jQuery. (See youmightnotneedjquery.com.)
There are a great many other popular JavaScript libraries. Browsers are not designed as repositories for JavaScript code. Tracking script popularity, dropping less popular libraries, and keeping everything up-to-date may be best left to web developers of individual sites.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme