PurgeCSS - Remove unused CSS from Web Pages

03-04-2023

PurgeCSS - Remove unused CSS from Web Pages

It is generally a good practice to remove unused CSS from web pages. As mentioned earlier, removing unused CSS can provide several benefits, including faster page loading times, improved website performance, reduced page weight, and better code maintainability.


it is generally a good practice to remove unused CSS from web pages. As mentioned earlier, removing unused CSS can provide several benefits, including faster page loading times, improved website performance, reduced page weight, and better code maintainability.
When there is unused CSS on a web page, the browser still needs to download and parse it, which can slow down the page loading time and decrease the website's overall performance. Additionally, unused CSS can make the stylesheet larger than it needs to be, which can increase the page weight and cause issues for users on slow internet connections or mobile devices with limited data plans.
Furthermore, removing unused CSS can make the code more maintainable and easier to work with in the long term, which can help to improve the website's stability and reliability over time. Overall, removing unused CSS is a best practice that can help to improve the user experience and website performance.

Why to remove unused css from web pages?

  1. Faster page loading: Unused CSS code still needs to be downloaded by the browser, which can slow down the page loading speed. By removing unused CSS, the page can load faster, which can improve the user experience and reduce bounce rates.
  2. Improved website performance: Removing unused CSS can help to reduce the amount of code that needs to be parsed by the browser, which can improve website performance and make the website more responsive.
  3. Reduced page weight: Unused CSS contributes to the overall size of the web page, which can increase the page weight. This can be a problem for users on slow internet connections or for mobile users who may have limited data plans. By removing unused CSS, the page weight can be reduced, which can improve the overall performance and user experience.
  4. Better code maintainability: Removing unused CSS can also make the code more maintainable. It can make it easier to find and fix issues with the code, and it can reduce the amount of code that needs to be maintained over time. This can help to improve the long-term stability and reliability of the website.
Overall, removing unused CSS can provide several benefits that can improve the user experience, website performance, and code maintainability.

Using PurgeCSS to Remove unused CSS from Web Pages

to use PurgeCSS, we need to have NodeJs installed in our system. Here is the simple simple example.


 
 purgecss --css ./style.css --content ./*.php ./assets/all.js --output ./output
 

Example Explained
for more info, please see purgecss.com/

Latest Published Blog


PurgeCSS - Remove unused CSS from Web Pages

PurgeCSS - Remove unused CSS from Web Pages

03-04-2023

It is generally a good practice to remove unused CSS from web pages. As mentioned earlier, removing unused CSS can provide several benefits, including faster page loading times, improved website performance, reduced page weight, and better code maintainability.


Installing Asterisk16 on CentOs7

Installing Asterisk16 on CentOs7

14-04-2022

Here is Step-by-Step Guide to Installing Asterisk16 on CentOs7.


Make CentOS7 Full Screen Like Primary Operating System in VirtualBox

Make CentOS7 Full Screen Like Primary Operating System in VirtualBox

01-03-2022

Learn How to Make CentOS7 Full Screen Like Primary Operating System in VirtualBox. After Installing CentOS in VirtualBox, CentOs Screen does not Occupy the Full Window Screen. Here in this Tutorial, We Will See how to do it.


Setting  Key to a Column For Quick Fetch Operation From Larze Records

Setting Key to a Column For Quick Fetch Operation From Larze Records

14-02-2019

To set a key to a column in SQL, you need to create an index on that column. An index is a data structure that allows the database to quickly look up records based on the values in the indexed column. By creating an index on a column, you can improve the performance of queries that filter, sort, or group by that column.