Check out the Minify and compress network payloads guide to learn more about tools to minify JS, and some complementary techniques, like compression. css files under src/main/webapp so that foo.js will be minified as foo-min.js and m圜ss.css will be minified as m圜ss-min. Minification can also be applied to other types of files. First, we need to declare that we will use the compressor plugin in our pom.xml file and execute the compress goal. In this guide, we've covered CSS Minification with webpack, but the same approach can be followed with other build tools, like gulp-clean-css for Gulp, or grunt-contrib-cssmin for Grunt. Since CSS files are render-blocking resources, if you apply minification on sites that use large CSS files, you can see improvements on metrics like First Contentful Paint. The report doesn't show "Minify CSS" as "Opportunity" anymore, and has now moved to "Passed Audits" section:
Click on Performance and find the Opportunities section.Both files are much smaller, in particular, the animate.css has been reduced in ~26%, saving ~20KB! You can inspect these files, and see that the new versions don't contain any whitespaces. Select the Disable cache checkbox if it isn't already.Press `Control+Shift+J` (or `Command+Option+J` on Mac) to open DevTools.To inspect the size and content of the files:
The button I circled here is the pretty printer which suddenly turns the code into something like this: Which is a nice start, but it is still very difficult to understand without some idea of what it looks like during execution.
If you got lost in any previous step, you can click here, to open an optimized version of the site. Here is jQuery.min in all its minified glory. Next, you'll check the result of this optimization with performance tools. This is how the resulting will look like: Take a look at the following CSS block: body ) ,Īfter making the changes a rebuild of the project will be triggered. In production, these characters can be safely removed, to reduce file size without affecting how the browser processes the styles.
CSS files can contain unnecessary characters, such as comments, whitespaces, and indentation.