Every web developer you will mostly encounter (a good portion of them anyway) is a liar. They’re lying to themselves, they’re lying to their colleagues and family, they’re lying to their employers. The biggest lie is being told since, “No honey, your butt doesn’t look big in those tight jeans”
What am I talking about? Javascript. Most developers if asked would tell you that they know Javascript quite well, but don’t know it as well as they should and actually really only know the frameworks they’re using, usually jQuery. This leads me to these questions: do many people actually know Javascript and have frameworks created a generation of developers who don’t know the underlying language they’re using? You’ve learned the framework, but do you understand the language?
The framework in question here is jQuery. Don’t get me wrong it’s the best thing to happen to web development, but just how many developers out there think $(selector) is something you can do in plain vanilla Javascript? How many developers out there opt for jQuery’s .each method instead of a good ol’ fashioned for loop just because it’s easier? While some of jQuery’s shortcut methods do save time, they are sometimes slower due to support for multiple browsers and having to do things a little differently to work within the constraints of the framework.
This JS Fiddle compares the performance of jQuery’s .each function with a for loop, provided you write a decently optimised for loop with caching it can be considerably much faster to the point where it does make a difference especially if you are iterating over large datasets.
There are tonnes of things that jQuery does people don’t realise would else-wise take a considerable amount of time to write, it saves time but usually at the cost of a slightly and sometimes a large performance hit. To be honest I feel like I don’t understand Javascript as well as I should, jQuery has made me lazy to the point where I’ve been more than guilty of writing less than ideal code just because I knew how to do it in jQuery but not how to do it in vanilla Javascript.
Browsers are at a point now where you can get away with writing bad Javascript, because Javascript engines of web browsers (especially Chrome) are so fast and efficient you don’t notice the 500ms performance hit you’re taking because you wrote a bad selector or loop.
For the sake of the language, think outside of the box every now and then like I’ve started doing. Take the time to find out how that particular jQuery method works and if there is a more efficient way of doing it and in the process making yourself a better developer who isn’t restricted to doing things one way and relying on a framework which is a position you should never find yourself in irrespective of whether or not you’re using Javascript or Ruby.