When to Use a JavaScript Framework?

One of my newsletter readers wrote me this

why use a JS framework? Could I not just make a website with html and css files using <script> to write my JS?

This is similar to asking "Why should I use a motorcycle? Could I not just get from A to B with a bicycle"

Yes, you can, but there are certain situations (like travelling 100 miles) where using a motorcycle would be more beneficial.

Specifically, I think there are three situations where choosing a framework makes more sense than using vanilla JavaScript.

1. Working on a complex project

If you’re working on a complex project, you might want to consider using a framework.

By complex, I mean a project that involves complex user interfaces requiring you to manage multiple states. You'll probably find yourself saving a lot of time by using a framework.

You would be focused on the project instead of worrying too much about some of the lower-level details.

2. Working in a team

If you’re working in a team, or with external developers, using a well-known, well-established framework with existing documentation help standardize the codebase and make it easier for everyone to collaborate.

3. Supporting different rendering methods

If you need to support different rendering methods, such as client-side rendering (CSR) or server-side rendering (SSR), frameworks provide it out of the box which is insanely beneficial.

You can do it with vanilla JS as well, but it gets really complicated.

Get my free, weekly JavaScript tutorials

Want to improve your JavaScript fluency?

Every week, I send a new full-length JavaScript article to thousands of developers. Learn about asynchronous programming, closures, and best practices — as well as general tips for software engineers.

Join today, and level up your JavaScript every Sunday!

Thank you, Taha, for your amazing newsletter. I’m really benefiting from the valuable insights and tips you share.

- Remi Egwuda