4 ms·
I am incredibly thankful that jQuery exists. The other day I had to code some basic javascript in a environment where embedding jQuery wasn't an option (too muc
by arkitaip 16y ago
I am incredibly thankful that jQuery exists. The other day I had to code some basic javascript in a environment where embedding jQuery wasn't an option (too much overhead) - boy what a PITA. Basic stuff like writing selectors took forever and I had to resolve to "low level" coding. What would have taken a couple of seconds in jQuery took several hours of research, and trial and error. I planned on adding a basic fading/sliding effect - forget about it. Takes to much time in ordinary javascript.
So thanks John Resig and the rest of the jQuery dev team for making us web dev guys more productive and actually making JavaScript fun.
- albertsun 16y agoOn the other hand... congrats! Now you know more about the inner-workings of jQuery and are a better javascript programmer.
- abp 16y agoQuestion is for how long. I've written several thousand lines of native, cross-browser javascript some years ago and from time to time again. But i don't remember a lot of the workarounds, from the top of my head. Fiddling with cross-browser support is something that my brain don't like to keep today, be it js or css. Things like jQuery for js and compass for css come in handy to brush over that. :)
- dualogy 16y agojQuery too much overhead? What kind of environment was that?
- bzbarsky 16y agoPretty much any environment where you care about performance of your code, actually. A lot of the simple-looking jquery stuff is implemented with tons of indirection, branching, etc. Just compare the work a browser has to do for something like: document.getElementById("foo").setAttribute("bar", "baz"); to the work needed for the jquery equivalent... Now the good thing is that most consumers of jquery don't care about performance of their code (in that they're doing small enough amounts of stuff it doesn't matter much).
- rorrr 16y agoOut of curiousity I tested that particular statement, and you're right. Compared to $('#foo').attr('bar', 'baz'); your code is 30 times faster in Chrome 9 81 times faster in Firefox 3.6
- tropin 16y agoCould you share your test code?
- ams6110 16y agoIn most cases, though, using jquery to do something like adding a class, or setting a value, is still plenty fast enough. We're talking about code that runs in the browser, where things move on human timescales. Don't optimize prematurely.
- bzbarsky 16y agoThe problems start when you add a class to 10,000 elements on the page. And yes, I've seen pages doing this with jquery where the jquery overhead was what made the difference between a 20ms operation (not user-perceptible) and a 1s operation (very much user-perceptible).
- mazuhl 16y ago47 times faster in Firefox 3.6.1 7 times faster in IE 8
- rimantas 16y ago> Now the good thing is that most consumers of jquery don't > care about performance of their code Many do, but more do care about cross-browser compatibility and when you need to support IE6,7 home-rolled code is not likely to cut all the research and effort that's embedded in jQuery.
- bradgessler 16y agoBookmarklets
- JonnieCache 16y agoRemember that jQuery's selectors can be used separately: they're a wrapper around the Sizzle library. It's 5kb after minification and gzip. http://sizzlejs.com/ http://sizzlejs.com/ Can't speak to the performance relative to JQuery or to raw javascript however.