How can I extract only the used CSS on a given web page and have that combined into a separate style sheet?

后端 未结 6 1731
梦毁少年i
梦毁少年i 2020-12-13 14:32

I have a site whose stylesheets are becoming overwhelming, and a full 50% to 90% or so is not used on certain pages. Rather than have 23 separate blocking CSS sheets, I\'d

6条回答
  •  北海茫月
    2020-12-13 15:29

    Try using this tool,which is just a simple js script https://github.com/shashwatsahai/CSSExtractor/ This tool helps in getting the CSS from a specific page listing all sources for active styles and save it to a JSON with source as key and rules as value. It loads all the CSS from the href links and tells all the styles applied from them You can modify the code to save all css into a .css file. Thereby combining all your css.

提交回复
热议问题