You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, PurgeCSS removes unused CSS by analyzing HTML or template files and stripping out selectors that are not referenced. It is possible in the CSS or by using whitelists to annotate CSS code, which should not be purged. This is however difficult to realize because it requires that the complete code is tested for all potential cases. This makes it nearly impossible to use the tool in large-sized projects.
The problem can be solved by using an opposite approach. By default, the complete CSS code should stay safe. It should be however possible via css selector or CSS annotation to annotate CSS which can be analyzed and purged. This would make it possible in large-sized projects to partially test elements for analysis and if tests are succeeding to enable purgecss for these elements.
Describe the solution you'd like
The solution can be realized similarly to the approach already used in safelisting (https://purgecss.com/safelisting.html). Instead of annotating the elements which are safed, it should however be possible to annotate elements which can be analyzed. This could be done with CSS like this:
/* purgecss analyze */ h1 { color: blue; }
h1 { /* purgecss analyze current */ color: blue; }
As alternative, it would be possible to split the CSS files to more modularized approaches. As soon as SCSS is however used with more complex mixins and functions, this approach is not working very well. The mixins are partially creating a lot of additional CSS code which are inserted in many css selectors and especially at this place purgeCSS could create a real benefit. But it should be only applied to a limited set of selectors and not complete files.
The text was updated successfully, but these errors were encountered:
Currently, PurgeCSS removes unused CSS by analyzing HTML or template files and stripping out selectors that are not referenced. It is possible in the CSS or by using whitelists to annotate CSS code, which should not be purged. This is however difficult to realize because it requires that the complete code is tested for all potential cases. This makes it nearly impossible to use the tool in large-sized projects.
The problem can be solved by using an opposite approach. By default, the complete CSS code should stay safe. It should be however possible via css selector or CSS annotation to annotate CSS which can be analyzed and purged. This would make it possible in large-sized projects to partially test elements for analysis and if tests are succeeding to enable purgecss for these elements.
Describe the solution you'd like
The solution can be realized similarly to the approach already used in safelisting (https://purgecss.com/safelisting.html). Instead of annotating the elements which are safed, it should however be possible to annotate elements which can be analyzed. This could be done with CSS like this:
/* purgecss analyze */ h1 { color: blue; }
h1 { /* purgecss analyze current */ color: blue; }
As alternative, it would be possible to split the CSS files to more modularized approaches. As soon as SCSS is however used with more complex mixins and functions, this approach is not working very well. The mixins are partially creating a lot of additional CSS code which are inserted in many css selectors and especially at this place purgeCSS could create a real benefit. But it should be only applied to a limited set of selectors and not complete files.
The text was updated successfully, but these errors were encountered: