hello and welcome to red stapler channel in this video I'm going to show you how
to remove unused CSS properties with automated tools called purgeCSS and
node.js to to analyze your HTML pages and JavaScript then remove all unused
CSS properties in just a few seconds ready let's check it out
purgeCSS is a node.js application so you need to have node.js installed once
that's done use npm install command in this video I'm going to install purgeCSS
globally by adding option -g this way you can use it on any types of projects not
just node now here is my sample HTML page from previous video let's try
adding some random CSS properties that we don't use to the CSS file
to begin the scan bring up the command prompt and type purgeCSS --CSS
followed by your CSS file name and --content followed by the content files
that you want to purgeCSS to analyze in this case let's put *.html to
make it scan through all HTML files purgecss will return purified CSS
that have all unused properties removed to the console well it's not quite
useful in this form so I'm going to create a new folder and run the tools
again but this time I'm going to add --out option followed by a folder name
this will make perch CSS right the result file instead of console
now you might have a question what if the CSS properties were added
dynamically during the runtime for example using jQuery addClass well
purgeCSS s is quite smart and able to detect that
let's try adding some JavaScript code to add a CSS class to div element and
include the js file into the page
now I'm going to run purgecss as again but also at *.js to the content option
now you will see that the class is not being removed this time as we expected
since the class is being used by a JavaScript so that's the basic of
purgeCSS but one important note is that you should test the result CSS file
before actually deployed to the project purgeCSS is quite smart but it's not
bulletproof so that's it hope you guys enjoyed this tutorial and please like or
subscribe if you want to see more video like this thanks watching and see you in
the next upload bye