When should you use a JavaScript library or framework instead of vanilla JS?
I advocate for using native browser APIs and JavaScript methods whenever you can.
But there are situations where I think it’s ok to use a library or framework.
- When you’re learning, if these tools help you go from zero to coding faster or let you grok concepts you otherwise couldn’t, that’s a good thing. Learning inertia is really important!
- When the thing literally wouldn’t exist otherwise, because you lack the skills to build it without a library or framework. Obviously, focus on building your skills, but that doesn’t happen overnight.
- When the native approach requires a lot of boilerplate/code around it. Image sliders come to mind here.
Bad reasons for using a library or framework include…
- Because you can’t be bothered to learn more about native methods/APIs.
- Because “it’s what everyone else uses.”
Unfortunately, these are often the reasons why people use these tools.