Production Builds Explained: Why They Matter?
3 min Read · Jan 4, 2024
I completely understand the uncertainty that comes with the understanding of production builds conceptually. As someone in the same position before, I can empathize with your feelings of not knowing what exactly production builds are.
However, this article is all about understanding builds. Instead of just writing commands (like npm run build, vite build etc…) or diving into the code directly, this article will walk you through the explanation of the builds.
Loading...
Rather than cramming thousands of lines into a single file, developers split their code into multiple files. Which focuses on the code’s quality and its impact on collaboration with multiple developers. However, production environments often encounter challenges when handling multiple files, when a user visits your site each of your files requires an additional API call to fetch that file from the server. Excessive API calls triggered by numerous website files can negatively impact loading times and performance. The more files your website has, the longer visitors will have to wait for pages to load completely, potentially hindering their browsing experience.
We can tackle these issues by implementing static file serving. Serving files as “static” means delivering them directly to users without relying on server processing. Static file generation involves taking dynamic content (like HTML, CSS, JavaScript) and pre-rendering it into fixed, unchanging files to enhance performance and also bundling multiple JavaScript or CSS files into a single file which results in fewer HTTP requests. The entirety of this process revolves around getting our app geared up for the production stage, a phase commonly termed as generating the “Production Build”.
Apart from this “Minification” is one of the essential components of Production Builds. This reduces file size by removing unnecessary characters (spaces, comments, etc.) while preserving functionality. which results in faster loading times and less bandwidth usage.
Generating a Production Build also involves other optimization techniques like: Code splitting | Tree shaking | Image optimization | Caching etc..
To simplify our build process, we use Build Tools that automate the entire process. Below are stats(till 2021) for some JavaScript-based build tools we use, for details visit State of JS.
Production builds optimise speed and efficiency by leveraging static file serving and minification, resulting in faster loading time and execution.
Did I explain things clearly?
I hope you found it valuable! I’d love your feedback and suggestions ☺️ If you see areas where I can improve, please don’t hesitate to reach out! 🔉on Email I’m excited to learn and grow with your help. 👋🏻