Post-process HTML with Prettier and Cheerio

Jeasx lets you rewrite the finished HTML with a response handler. It is set on this.responseHandler, receives the rendered payload and returns the new text. This page rewrites its very own markup.

Extract inline styles with Cheerio

Cheerio turns all inline styles into CSS classes in the head of the page.

  1. RenderJSX produces HTML full of inline style attributes.
  2. CollectCheerio finds each declaration; identical ones share a single class.
  3. 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.

Original sourcebefore
Rewritten markupafter