6 ms·
Why would you include ES5 shims instead of using code that's well tested, already written, and bundled in a neat package. jQuery is the de-facto DOM library (w
by tbranyen 15y ago
Why would you include ES5 shims instead of using code that's well tested, already written, and bundled in a neat package.
jQuery is the de-facto DOM library (whether it should be or not), failure to see this is ignorance.
- oinksoft 15y agoWhy would you include ES5 shims instead of using code that's well tested, already written, and bundled in a neat package. I'm not sure how much you really need to test an each() loop. It is a very simple thing as are most of the other features introduced in ES5 that can be shimmed. jQuery doesn't include many of these new features, and I disagree with you that you should just omit them from your code because your DOM library, of all things, doesn't include them. All the ES5 shims do is implement these functions exactly to the standard, and doing so is a very simple thing. Further, the code in a shim is only run in old versions of IE: New IE, and pretty much all running versions of non-IE browsers, implement these functions in native code (which obviously is much faster). jQuery does not defer to Array.prototype.forEach if it is available. jQuery is the de-facto DOM library No, it really isn't. There's a huge distance to travel from being the most popular to being "de-facto."
- tbranyen 15y agoWell I'd love to know which DOM library you're hiding behind your words, that you believe is de facto.
- oinksoft 15y agoThere is no de facto DOM library. I just said as much ... jQuery would be "de facto" if projects adopted it without a second thought, and in my experience this doesn't happen except with beginners.
- Jare 15y agoThese 'beginners' are building working sites left and right every day. They don't need to feel they are on the bleeding edge of html, they just want their stuff to work reliably with a reasonable cost. Most of them don't write blogs, don't have githubs, don't own node packages. They develop web sites the same way that you and I drive our cars. They adopt jQuery without a second thought, and why shouldn't they?
- FuzzyDunlop 15y agojQuery's extreme ubiquity arguably makes it the de facto DOM abstraction library, and this does conform to the definition. Its demographic, or target audience, is irrelevant, because it is everywhere, and much to the detriment of 'pure javascript' (some might argue). It'll remain that way until differing browser implementations converge and obviate the need for an abstraction that papers over the cracks.
- jonstjohn 15y ago>> Using an ES5 shim is best-practice these days Hmmm, seems like a huge distance to travel from being 'I think ES5 shims are awesome' to a 'best-practice' these days. I'd be hesitant to use the kriskowal library in production, especially since it states 'This package requires quite a bit more attention and testing. It is not likely to behave as advertised in a large cross-section of browsers.'