Together with Marcel Pociot and our colleagues at Beyond Code and Spatie, I'm currently building Flare, a paid service which will be revealed at Laracon EU. Together with the service we'll release a package that will change the way you will work with Laravel. To stay in the loop subscribe to our mailinglist at

Reducing the size of a css file

Original – by Freek Van der Herten – 2 minute read

PurgeCSS is a tool that can reduce the filesize of a CSS file. It does this by removing any css classes that are not used. It can detect which CSS classes are used by scanning the source files of your application.

In this tweet Jonathan Reinink shared how it can be configured in Laravel Mix:

Jonathan mentions massive reductions in the filesize of a css. Let's take a look at how much is massive. This is the output of yarn run production for before installing PurgeCSS.

stats before purgecss

155 kB for front.css and 162 kB for back.css. Not bad. Let's add PurgeCSS.

stats before purgecss

The resulting files are 90% smaller. Pretty impressive!

If you want to know more about PurgeCSS be sure to check out this blogpost by Andrew Del Prete.

Stay up to date with all things Laravel, PHP, and JavaScript.

Follow me on Twitter. I regularly tweet out programming tips, and what I myself have learned in ongoing projects.

Every two weeks I send out a newsletter containing lots of interesting stuff for the modern PHP developer.

Expect quick tips & tricks, interesting tutorials, opinions and packages. Because I work with Laravel every day there is an emphasis on that framework.

Rest assured that I will only use your email address to send you the newsletter and will not use it for any other purposes.