4 ms·
I dislike when people say that good developers don't use libraries like jQuery. The main reason I use them is because I'm lazy. I'd much rather write $("#id") t
by jasonlfunk 12y ago
I dislike when people say that good developers don't use libraries like jQuery. The main reason I use them is because I'm lazy. I'd much rather write $("#id") than document.getElementById("id"). I rarely write any javascript code that is so resource constrained that the extra time added by jQuery is not acceptable.
- enraged_camel 12y agoThe actual quote was: >>What I’m saying is don’t rely heavily on jQuery, or any other library, without having some sort of understanding of how that library is accomplishing it’s tasks. Which I think is fair. (However, I don't agree with his assertion that using vanilla JS will be more efficient - in most cases, it won't.)
- Bahamut 12y agoVanilla JS is more efficient than jQuery a lot of the time - for example, consider the $(...) api - this has to do string parsing before it makes its selector call, which by its very nature take away computing power. These days it is negligible though. The argument for using jQuery for DOM manipulation is oftentimes just one of readability.
- tonyonodi 12y agoIIRC jQuery started out using string parsing to achieve this but its widespread use prompted browser vendors to add the document.querySelector and document.querySelectorAll methods to their browsers. Probably in older browsers it still uses the old method but for modern browsers it just passes [selctor] in $("[selector]") through document.querySelectorAll; no string parsing necessary.
- enraged_camel 12y agoI think by "efficiency" the author meant developer efficiency, as in writing more code in less time. I may be wrong though. You're definitely right that vanilla JS is often times more efficient than jQuery.
- pkorzeniewski 12y agoIn 99% cases the performance difference doesn't matter - users won't notice that a jQuery method runs 5ms slower than it would run in vanilla JS, but they will notice if the script doesn't work at all, because your vanilla JS code fails on older browsers.
- Bahamut 12y agoI agree for the most part - I'm just making a theoretical distinction.
- skizm 12y agoI'm guessing people don't mean that if you used jQuery you are a bad developer. Just that, if you are a good developer, you don't rely on it and can write the vanilla version if needed. EDIT: In this case, I'm wrong, the author seems to think you should write vanilla when given the option which is wrong for a lot of reasons.
- pkorzeniewski 12y agoLaziness is one thing, but jQuery covers so many browser-specific issues and differences that it would be insane to cover it all by yourself. Sure, if you have a simple script with several lines of code than you can go without jQuery, but anything more complex - no way, you will produce 10x more code with 10x more bugs. The only argument against using jQuery could be its size, but let's be honest - nowadays, unless you do something targeted at users with very low connections, it doesn't matter, even on the mobile.