declassify
Remove any classes or IDs not found in CSS from HTML - modifies HTML, not CSS.
This only considers CSS contained in the HTML document inside <style>
tags to be in use right now. Currently limited to modifying class
and id
attributes, so won't do anything with [data]
or other attributes less commonly used in CSS.
npm install declassify
Example
var declassify = ;var result = declassify;
Input:
Output:
// has removed class="unused" // has removed unused-class
Options
var declassify = ;var options = ignore: 'ignored-class' /ignored-regex-class\-[0-9]+/ 'ignored-id' /ignored-regex-id\-[0-9]+/ attrs: 'id' 'class';var result = declassify;
Input:
Output:
There are some other methods exposed by the module which can be considered public and will be considered for versioning, but please see index.js
if you think you might need to use any of them.