Run penthouse as a serverless function on Vercel.
Make a post request to <domain>/api/penthouse
with following body:
{
"url": "<absolute url to page you want you want extract CSS>",
"cssPath": "<absolute path to css file>"
}
Alternatively, you can post HTML and CSS as strings instead of absolute paths.
{
"html": "<valid html string>",
"cssString": "<full css string>"
}
The function will return an object with critical CSS as follows:
{
"criticalCss": "<critical css string>"
}