DEV Community

Discussion on: What is a Web Framework, and Why Should You use one?

sandeepkamboj12 profile image
Sandeep kamboj

All the frameworks and libraries are built upon CSS and JAVASCRIPT.

To use just few method or to implement some functionality we need to load whole library.

Why not built all things in just using CSS and Javascript.

thorstenhirsch profile image
Thorsten Hirsch

Because even a whole library is not really big. Let's look at React for example, it's ~100kB (including react-dom). Is that much? We need to compare this size to all elements of a website. Even though Ben has optimised its CSS still has ~200kB (the page you are currently looking at) and we haven't even taken a look at the size of all the images, yet!

But it gets worse. Since react is a standard library that is being used on many websites, chances are good that react.min.js is already in the browser cache. So it does not need to be transferred another time. But when you write your own library in order to save some bytes, how are the chances that your library is already in your user's browser cache?

And a 3rd point to think about: react is being built by some of the most brilliant developers, top experts who know javascript inside-out. React is heavily optimised. Even though it is 100kB in size it probably renders pages faster than a much smaller competing library or your own code.

Summary: a library that has 1/10 of react's size does not give you 10x performance improvement - instead it might even be slower than react. However you might want to take a look at Preact.