Have you ever noticed these people? Ask them the most simple JavaScript question and they'll respond with the answer in jQuery, even if that answer's a lot more complicated.
I was on another forum and someone asked a question about shortening getElementsByTagName. He wanted to be able to do this:
The function "getID" was a simple short-cut for document.getElementById but the asker wanted to know how add a method to that function, although didn't know how to phrase it. Want to see the first response?
That is not an answer - that's not even close! The jQuery solution would create a jQuery object (or an array of jQuery objects, as it happens), document.getElementsByTagName creates a NodeList. To make something approaching the response the original asker was expecting, you'll need this:
That's not a NodeList, that's an Array, but they're close enough - certainly closer than it was. However, of course, there's one important thing missing from the top of that solution:
This is what I mean by a jQuery fan-boy. They don't think in terms of JavaScript, they think in terms of jQuery and expect everyone else to think the same. The jQuery solution would work and give access to all the jQuery methods, but for such a simple example it's far too complicated and totally unnecessary. But the thing I really hate about jQuery fan-boys? I can't tell them that they're being idiots without looking like the bad guy.
The sad truth is that calling them out won't help anyone, all I can do is offer a vanilla JavaScript solution and hope that it makes more sense than their one while teaching them something useful in the process. As much as I want to tell these fan-boys that they're not helping, the very most that I can do is blog about it.
To all you jQuery fan-boys: every time you try to say that the easiest solution is to use jQuery, be aware that you are adding a massive complication to a simple solution; jQuery is not always the best solution and certainly not the only solution. Before you say it is, please ask yourself the following questions:
I truly believe that if you can not answer these questions, you are not a competent coder and should not be offering advice.
I was on another forum and someone asked a question about shortening getElementsByTagName. He wanted to be able to do this:
var myInputs = getID('myid').getTag('input');The function "getID" was a simple short-cut for document.getElementById but the asker wanted to know how add a method to that function, although didn't know how to phrase it. Want to see the first response?
$('#myid input');That is not an answer - that's not even close! The jQuery solution would create a jQuery object (or an array of jQuery objects, as it happens), document.getElementsByTagName creates a NodeList. To make something approaching the response the original asker was expecting, you'll need this:
var myInputs = [];
$('#myid input').each(function() {
myInputs.push(this);
});That's not a NodeList, that's an Array, but they're close enough - certainly closer than it was. However, of course, there's one important thing missing from the top of that solution:
<script type="text/javascript" src="path/to/jquery.js"></script>
This is what I mean by a jQuery fan-boy. They don't think in terms of JavaScript, they think in terms of jQuery and expect everyone else to think the same. The jQuery solution would work and give access to all the jQuery methods, but for such a simple example it's far too complicated and totally unnecessary. But the thing I really hate about jQuery fan-boys? I can't tell them that they're being idiots without looking like the bad guy.
The sad truth is that calling them out won't help anyone, all I can do is offer a vanilla JavaScript solution and hope that it makes more sense than their one while teaching them something useful in the process. As much as I want to tell these fan-boys that they're not helping, the very most that I can do is blog about it.
To all you jQuery fan-boys: every time you try to say that the easiest solution is to use jQuery, be aware that you are adding a massive complication to a simple solution; jQuery is not always the best solution and certainly not the only solution. Before you say it is, please ask yourself the following questions:
- Is jQuery really the best library to use? What about YUI, Prototype, Dojo or any of the other libraries? Is jQuery the fastest or most efficient -- and can you prove it?
- Do you really need the whole of jQuery, or are you just relying on Sizzle? Wouldn't only loading Sizzle be easier?
- Is there a vanilla solution to the problem that is faster or more efficient? If so, why is it better to use jQuery?
I truly believe that if you can not answer these questions, you are not a competent coder and should not be offering advice.
3 Comments On This Entry
Page 1 of 1
Help














Just because something can be done at a low level does not mean it is the best solution - that is why higher level programming models evolved in the first place. I'm sure glad I rarely have to write in assembler anymore, it just isn't necessary.
I get your points but I think it goes too far the other way. Getting to grips with JS is certainly going to be useful, but for people new to web, wanting to get stuff done, jQuery, YUI or whatever are entirely suitable solutions.
My rant isn't against professional developers who realise the value of a well-documented library, but against that peculiar sub-set of JavaScript coder who believe that jQuery is the ultimate for of JavaScript and will always respond to a basic JavaScript question with a jQuery solution.
The cost is not negligible, for example:
Hardware (Web-Servers, Database Servers, Load Balancers).
Systems Administrators, managing the increasingly complex infrastructure.
Website Bloat, User Scripts executed on user side.
MOBILE DEVICES (NetBooks, Tablets, SmartPhones)
IMO If something *CAN* reasonably be done efficiently, it should. If doing it inefficiency cuts Dev time, enough to be worth the cost, you take the trade-off. Inefficiency is the exception to the rule of efficiency, that is where Devs get it wrong.