GoogleChromeLabs / critters

🦔 A Webpack plugin to inline your critical CSS and lazy-load the rest.

Home Page:https://npm.im/critters-webpack-plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request: Expose method `processCss` which returns inlined css only

Warxcell opened this issue · comments

commented

Use-case is to be able to use critters inside SSR, by processing only CSS and caching processed CSS - allowing the content to evolve independently from the processed CSS. Something like

let html = .... rendered html in ssr ...
const cacheKey = .... some logic ....
const criticalCSS = getInlinedCriticalCSSFromCache(cacheKey) ?? critters.processCss(html);

html = html.replace('</head>', criticalCSS + '</head>')

This will help also with #78