The folks from CSS Stats have created get-css, a package to get all the CSS from a given webpage. One downside, however, is that it only works for server side rendered applications.
This package uses an actual browser under the hood to get all the CSS and exposes an HTTP endpoint that accepts a url to get the CSS from.
I have no idea how local testing for Now is supposed to work, so I created a tiny HTTP server in dev.js
that calls the actual function that gets deployed.
Run npm run dev
to run a local version of the function for local testing.
You can optionally add all the custom HTTP headers you want to this service request by attaching them in a encoded query string named extraHeaders
, that way your destination URL request will have also such headers. See the following example:
https://get-critical-css-service.vercel.app/m?extraHeaders=%7B%22X-Custom-Token%22%3A%22123456%22%7D
Using Now: now
.
- This repo is pretty much an exact copy of this example from Zeit.
- The idea to get all the CSS from a webpage comes from CSS Stats