
#POSTCSS MINIFY CODE#
It reduces code file size by stripping out unwanted spaces, characters, and formatting, resulting in fewer characters in the code.

This means the user will potentially be unable to see any content on a webpage until the browser has built the CSSOM (the DOM but with CSS information), which only happens after it has downloaded and parsed all style sheets referenced by the document. However, what is critically important about minifying CSS is that CSS is a render blocking resource on the web.
#POSTCSS MINIFY DOWNLOAD#
As such, we add spacing, indentation, comments, naming conventions, and instrumentation hacks to boost our productivity and the maintainability of the CSS code - none of which the browser or target platform needs to actually run it.ĬSS minification allows us to strip out these extras and apply a number of optimizations so that we are shipping just what the computer needs to execute on the target device.Īcross the board, source code minification reduces file size and can speed up how long it takes for the browser to download and execute such code. Like other forms of code, CSS is primarily formatted for human consumption. Ultimately, code is meant to be executed by computers, but this is after or alongside its consumption by humans, who need to co-author, review, maintain, document, test, debug, and deploy it. Minification helps to cut out unnecessary portions of our code and reduce its file size. Only recently did the web begin to pay attention to issues emanating from poorly optimized CSS.ĬSS minification is an optimization best practice that can deliver a significant performance boost - even if it turns out to be mostly perceived - to web app users.
#POSTCSS MINIFY HOW TO#
Thus, there has been a lot of focus on reducing JavaScript payload sizes, including how to split them into reasonable chunks and minify them. More code could mean more complexity, poor performance, and low maintainability.

The less code we ship through the web, the less friction we create for our applications and our users.

Given the need to build web-enabled apps that match or outdo their native counterparts in behavior and performance (thanks to SPAs and PWAs), we are now shipping more functionality and more code through the web to app users.Ĭonsidering the ubiquity of the web, its very low friction (navigate through links, no installation), and its low barrier to entry (internet access on very cheap phones), we will continue to see more people come online for the first time and join millions of other existing users engage on the web apps we are building today. The web would be either completely broken or utterly boring without CSS. It’s responsible for the intuitive visual cues that communicate application state such as a network outage, a task completion, an invalid credit card number entry, or a game character disappearing into white smoke after dying. In the following configuration the plugin postcss-preset-env is used, which is not installed by default.Odili Charles Opute Follow Husband | Dad | Developer | Bass Player | ex Dev Community Manager | Distributed Learning Design and Bootcamp Manager Opinions are mine! The complete best practices for minifying CSSĬSS is what makes the web look and feel the way it does: the beautiful layouts, fluidity of responsive designs, colors that stimulate our senses, fonts that help us read text expressed in creative ways, images, UI elements, and other content displayed in a myriad of shapes and sizes. Then add the plugin to your webpack config.
#POSTCSS MINIFY INSTALL#
To begin, you'll need to install postcss-loader and postcss: npm install -save-dev postcss-loader postcss For Webpack v4, you have to install postcss-loader v4. You need webpack v5 to use the latest version.
