After discovering JQuery for the first time, I couldn't believe how simple it was to rapidly develop dynamic web content. I was blown away by how simple it was to manipulate a website's DOM, ajax calls could be executed with a single function and a wide variety of plugins are available by the thousands. However, after looking at the networking data for my latest web project I was shocked to find that the largest file my site loaded was JQuery raising the question, "Do I really need this library?". Now I'm forced to weigh out the benefits and disadvantages of implementing JQuery in my projects.
The JSPerf results showed that native ID selection is a shocking 5365% faster than element selection from JQuery:
Then again, unless you're planning on manipulating thousands of elements at a time, you probably wouldn't even notice the difference in speed. I think it all really comes to this:
- Manipulation of thousands of elements is nessesary.
- Mobile efficiency is a major focus.
- You don't need a lot of animated content.
- Little to no AJAX is used in your website.
- Speed (down to the milisecond) is absolutely crucial.
- Reinventing the wheel isn't a big issue for you.
Use JQuery when:
- You need good documentation and a good community for support.
- Rapid development through implementing plugins seems applicable.
- You don't mind waiting an extra ~300 miliseconds for JQuery to load.
- The mobile market isn't your primary focus.