
Tell HN: jQuery is way slower than plain Javascript - mandeepj
http:&#x2F;&#x2F;jsperf.com&#x2F;jquery-vs-document-queryselector<p>http:&#x2F;&#x2F;jsperf.com&#x2F;jquery-css-vs-native-dom<p>http:&#x2F;&#x2F;www.leebrimelow.com&#x2F;native-methods-jquery&#x2F;<p>http:&#x2F;&#x2F;jsperf.com&#x2F;comparing-jquery-and-native-js&#x2F;11
======
jaachan
Running speed is good enough, development time is way down. Kinda like using
C# rather than ASM. What's the problem?

------
lifeformed
Not if you're talking about development time!

------
obsession
I really _hate_ these kinds of benchmarks. No-one will ever have jQuery as a
bottleneck on their application.

~~~
migstopheles
First 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
> 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

------
jvvlimme
Yep. 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
The 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
i 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

------
lightblade
This 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.

------
CmonDev
News flash: imperative code is faster than functional monadic code.

------
mattwritescode
Well of course its going to be. A better comparison would be at the least two
javascript frameworks.

