Ah, I've been asked many times if people should stick with native Javascript, or use a Javascript library like jQuery.
Short Answer: Use jQuery.
Longer Answer:
Why? jQuery is by far the best JS library I've used. It doesn't just take the tediousness out of writing javascript, but it makes it downright FUN. Using jQuery, you're able to write in 1 line of code what would take you 10-15 lines of code using native javascript!
It's very lightweight, fast and has a minimal footprint. It weighs in at about 26KB minified & gzipped.
jQuery gives you the ability to execute code when the DOM is loaded, not just when the window entirely is loaded (meaning all graphics & other external resources). Not only that, but you can specify in multiple areas what code to execute when the DOM is loaded.
jQuery supports CSS 1-3 selectors which dramatically reduces the amount of code you need to write to get your work done. It handles animations, AJAX calls, DOM manipulation, and more with sheer elegance and beauty. Extending jQuery is where it really shines. You can find a plugin for nearly anything you'll need.
If you've ever dealt with native Javascript for anything beyond the most elementary of tasks, you'll probably have discovered that cross-browser compatibility issues sneak up on you in a hurry. jQuery takes care of this. It is fully cross-browser compatible, and is frequently updated to ensure that it remains cross-browser compatible, fast, lightweight and bug-free. This is one of jQuery's most powerful assets.
Still not convinced? Here are just a handful of BIG NAMES that use jQuery:
- Google
- Dell
- Bank of America
- digg
- Netflix
- Mozilla
- WordPress
- Drupal
I encourage you to spend a few hours playing with jQuery and discovering first-hand just how powerful it is. The learning curve is minimal, and the benefits are tremendous. jQuery is THE javascript library to use. You'll spend more time getting things done, and less time coding.
As always, I'd love to hear what you think. Leave me a comment with your thoughts!