Extract inline styles with Cheerio
Jeasx lets you post-process the finished HTML with a response handler. This example uses Cheerio to turn all inline styles into CSS classes in the head of the page.
- RenderJSX produces HTML full of inline style attributes.
- CollectCheerio finds each declaration; identical ones share a single class.
- RewriteClasses go into one style tag in the head and Prettier formats the result.
Compare the original and the rewritten markup of this very page below.