Why is jQuery not integrated within the browser

前端 未结 7 1164
死守一世寂寞
死守一世寂寞 2020-12-06 16:20

Why isn\'t jQuery intergrated into browsers, so there would be no need to have to reference it on your site, and instead, the browser just notices the jQuery used, and every

相关标签:
7条回答
  • 2020-12-06 16:32

    First, there's nothing special about JQuery - it's just a more human-friendly way to code JavaScript. It takes care of more cross-browser quirks, etc. so the developer doesn't have to think about it so much.

    That being said, JQuery follows ECMAScript standards, and so do browsers. IE is a stubborn one because it uses proprietary JScript not JavaScript.

    The browser shouldn't handle that burdon. Do you really want to go back to the days of bloated browsers that hog 500+mb of ram and take 10 seconds to open?

    On a final note, if Mozilla and Webkit just started including JQuery, it would probably piss off a lot of talented JavaScript devs who use Mootools, YUI, Dojo, etc.

    0 讨论(0)
  • 2020-12-06 16:33

    Well, for one there are several versions of jquery, some plugins aren't compatible with newer versions, also if, lets say firefox, DID implement this, they would have to download jquery each time there's an update, there's no guarantee that chrome and other browsers would follow up on this, for example internet explorer that doesnt seem to like anything new, so you would still have to reference it for the browsers that does NOT support it.

    Final not from here is, even though browsers would start to implement it, I wouldn't rely on that anyway.

    0 讨论(0)
  • 2020-12-06 16:35

    Just wanted to point out that a similar question has been asked on Webmasters Stack Exchange and you can find some other good answers there:

    • Why don't browsers have jQuery installed?
    0 讨论(0)
  • 2020-12-06 16:40

    Because then different browsers would have different incompatible versions.

    Any native implementation is guaranteed to have some subtle difference from the real thing; eventually, we would need a cross-browser jQuery wrapper, and the cycle would repeat.

    It would also make updates much more complicated.

    It would also break other libraries that define $ functions (eg, Prototype).

    0 讨论(0)
  • 2020-12-06 16:43

    THE main advantage of having jQuery in an external script is that you can obtain a new feature in a new version of jQuery and (assuming jQuery did proper cross-browser support), you can automatically have that feature available in all the browsers your viewers use. You can code your site to use that new jQuery feature and know that it will work in all browsers in common use.

    If jQuery functionality was built into the browser, you'd be stuck with a least common denominator approach. You could rely on no more features than were in the most backward browser or oldest browser that you wanted to be compatible with. When a new feature was introduced, you'd have to wait nearly a decade for all older browsers that don't support that new feature to drop out of common use before you could be sure it was safe to use. Or, you'd have to build your own cross-browser support for it, thus creating a new jQuery-like cross-browser library and the circle would start over again.

    With jQuery, you just include the newest version of the library in your site and you can automatically use that new feature in all common browsers.

    As for efficiency, you aren't losing much by including jQuery as an external file is it is done properly. If you use one of the more common CDNs (like Google) to link to jQuery, then jQuery is probably already in the browser cache and it's loaded from local hard disk rather than downloaded each time it's needed. Yes, it could be optimized further if it was built in, but then you lose all those benefits talked about earlier which negates the whole reason for having it in the first place.

    Also, it's not like the built-in capabilities aren't moving forward every year. They are. It's called the standards movement. The issue is that it moves very slowly. Look at CSS3 transitions. We have CSS3 transition support today in all popular versions of Firefox, Chrome, Opera and Safari, but not in any version of IE yet. So, since we're still a long ways from all popular use of IE7, IE8 and IE9 disappearing, we're a long ways from being able to just "use" CSS3 and expect the browser to support it. An animation library is still needed. Even if IE10 shipped tomorrow and automatically supported all of CSS3 transitions, we'd still be many years away from when all older versions of IE stopped being used on the web.

    0 讨论(0)
  • 2020-12-06 16:44

    All JavaScript libraries should be integrated into a browser, which therefore uses a global storage for them (like Google, for example) so that when one library is updated, it will also be updated on that one storage center. That would be one way how, whatever the browser version, libraries won't be outdated. As for the dollar mark, I figure some function should be created by a browser like ..

     use_library( 'jquery' ){
         // my jquery code
     }
    
     use_library( 'prototype' ){
         // my prototy[e code
     }
    

    However, since integrating JavaScript libraries will only be effective when the browser won't load it via internet on each request, rather only on a library update and then only once, too, it needs to have some sort of a "cool" system that checks for a new library once a day or so, making as little request as possible.

    My 2 cents.

    0 讨论(0)
提交回复
热议问题