Choosing Vanilla JavaScript

A lot of JavaScript developers out there, myself included, love jQuery. And rightly so! Like any great tool, it makes our lives easier. When building something with a large amount of front-end code, like a robust site or application, jQuery is a powerful ally.

However, if you’re building a small- to medium-sized library, you should seriously consider using vanilla JavaScript. Sometimes it makes sense to put down the power screwdriver and use some good old-fashioned elbow grease.

You Might Not Need jQuery is a fantastic resource that is sure to come in handy in these situations. It matches up snippets of the jQuery code you know and love with their vanilla JavaScript counterparts. It’s a straightforward way to see exactly what jQuery is doing for you.

Seeing the code side by side is useful for both ends of this conversation (notice it’s called You Might Not Need jQuery, not You Don’t Need jQuery). The difference between selecting elements in jQuery and in vanilla JavaScript is not as large as the difference between animation code. If you’re heavily reliant on element selectors, you might opt to go with vanilla JavaScript. But if you’re making heavy use of animation, jQuery may be your choice.

Historically, jQuery has been a great tool because it handles all cross-browser issues itself. To that end, the makers of You Might Not Need jQuery explain:

Some developers believe that jQuery is protecting us from a great demon of browser incompatibility when, in truth, post-IE8, browsers are pretty easy to deal with on their own.

If you don’t use jQuery, you have a choice to make: either write the code to solve browser compatibility issues yourself, or build a progressively enhanced experience. After all, JavaScript shouldn’t be required to use what you build. Weigh the benefits of writing vanilla JavaScript (fewer requests with less data to load by not including jQuery, among others) against the fact that certain browsers won’t get the full experience. Like everything in our line of work, choose the route that’s right for you, your team, and what you’re building.

  • By The fine folks at A List Apart
  • Posted in Uncategorized
  • Tagged browser
  • Translator

  • Recent Articles

    • ECS Liva X Mini PC Now Available From $210
    • The Best Free Partition Manager for Windows
    • PlayStation 4 Ironclad Tactics Launches Tomorrow, January 20th (video)
    • New Sony Handset Appears At FCC Could Be The Xperia Z4
    • This Is How Xiaomi Keeps The Cost Of Its Smartphones So Low
    • Nokia Lumia 635 Now Available From Sprint
    • Turkey Threatens To Block Twitter
    • Mark Thoma posted an entry
    • The Wisdom of No Escape: Pema Chödrön on Gentleness, the Art of Letting Go, and How to Befriend Your Inner Life
    • 12 Inch iPad Pro May Come With A Stylus
    • This is NOT How to Turn iPhone Devices into a “Wearable”
    • Samsung drops Galaxy S3 Neo price to INR 12,499
    • Hutchison Whampoa May Buy O2 UK From Telefonica
    • Call Of Duty: Advanced Warfare Secret Gun Glitch
    • HTC One M9 And HTC SmartWatch Coming AT MWC 2015
    • Veteran World Of Warcraft gamers get a special statue in the mail
    • Playing Rock Band With Others Could Increase Empathy Levels
    • Chinese Education App XueXiBao Raises $20M Series B From SoftBank And GSR
    • Sony To Close 14 Sony Stores In Canada
    • HTC One (M8) successor to include Ultrapixel front camera: Report