What happens when we build JavaScript applications?
In JavaScript we need to build our application before deploying, mostly that’s known as the production build. We use commands like this npm build. but have you ever thought about what happens when we build an application and why we should do it? Let's discuss the same.
We know that JavaScript has one of the largest collections of packages we can install and import those packages in our project. it increases code reusability. but sometimes we install lots of packages and after a while, we stop using it but we never delete it. It's similar to writing unnecessary code. This increases processing time our JavaScript engine unnecessarily processes nonuseful code which is not at all good especially when the project in production mode.
When we use npm build commands our code either gets converted into vendor code or code chunks. vendor code is nothing but a bundle of imported npm _module in our project . one of the potential advantages of keeping our application code and vendor code separate is it helps to improve catches.
node_modules codes don't change so often we can keep those files in the cache to avoid loading files each time when it is loaded the first time it gets stored in the local browser cache and whenever a request made related to the file it first gets checked in the cache if that file is present in the cache then it directly gets served. otherwise, it gets loaded from the server. This technique reduces server calls and saves data costs and also improves speed.

0 Comments