4 ms·
Tell HN: jQuery is way slower than plain Javascript
http://jsperf.com/jquery-vs-document-queryselector
http://jsperf.com/jquery-css-vs-native-dom
http://www.leebrimelow.com/native-methods-jquery/
http://jsperf.com/comparing-jquery-and-native-js/11
- jaachan 13y agoRunning speed is good enough, development time is way down. Kinda like using C# rather than ASM. What's the problem?
- jvvlimme 13y agoYep. Nobody ever claimed it wasn't. jQuery adds padding for browsers that don't support certain features or have certain quirks (yes, IE, we're mainly looking at you). This is overhead that will slow things down. That being said, if you can afford to develop for modern browsers only, then by all means, use plain JS.
- masswerk 13y agoThe other (more traditional way) would be to address anything in plain JS and add special code to handle things for IE, rather than piping all browser through some abstraction layer. (Same applies for other, non-UI-specific JS: Need Array.forEach()? Use it. Define Array.prototype.forEach() for legacy IE, rather than piping all browsers through "MyLib.forEach(myArray, function(item) {... })".)
- bowerbird 13y agoi don't wanna have to check everything i use to see if it has any browser incompatibilities this week... and i certainly don't want to do the work of figuring how to sidestep incompatibilities that _are_ present. even if the distastefulness of _that_ was half as bad, i would still rather make my users "wait" for that 37k. again, that's _me._ not telling anyone else how to do it. -bowerbird
- jvvlimme 13y agoThat's how jQuery works internally. It checks if function is available in the current browser, if not it will apply a workaround.
- lifeformed 13y agoNot if you're talking about development time!
- obsession 13y agoI really hate these kinds of benchmarks. No-one will ever have jQuery as a bottleneck on their application.
- migstopheles 13y agoFirst thing that pops to mind is jQuery animations vs CSS transitions/keyframe animations, especially on low-powered mobile devices. I guess that's not explicitly jQuery vs JS, but it's still an example of how it can be done far better. There's also the fact that you don't have to include a gigantic library of functions you'll never use, just to show a box when you click a button. 37kb is way over 10% of my ideal page load for a simple to moderate site.
- bowerbird 13y ago> 37kb is way over 10% of my ideal page load i'd say 87% of the pages on the web have graphics whose importance is sketchy, and whose total size dwarfs 37k. and since i almost always do _something_ which has been found to show cross-browser inconsistencies, the peace that jquery gives _me_ is well worth those paltry 37k... that's me. other people might be different. but that's me. -bowerbird
- CmonDev 13y agoNews flash: imperative code is faster than functional monadic code.
- mattwritescode 13y agoWell of course its going to be. A better comparison would be at the least two javascript frameworks.
- lightblade 13y agoThis is using jQuery 1. You should be using jQuery 2 for this kind of benchmark. As other already said, jQuery adds a lot of padding to support older browsers. jQuery 2 removed a lot of old browser support for performance improvements.