next-preload-headers
v3.0.4
Published
next.js static assets upgraded to preload response headers
Downloads
616
Maintainers
Readme
next-preload-headers
express middleware that adds preload tags in body of initial response into header where proxy will generally upgrade them to http2 server push. Server pushing critical assets improves response time, especially for mobile users.
Usage
npm install --save next-preload-headers
Add it to the express server.js like this:
const nextPreloadHeaders = require('next-preload-headers')
const app = express()
app.use(nextPreloadHeaders)
TODO:
- add css to the top of the list since it is generally the most important
- send/check a cookie with buildId so we know if resources need to be pushed for this build
- consider sorting style elements first
- figure out why sometimes getting "can't add headers to already sent response". I think this is just an HMR issue in dev.
##Changelog:
- 3.0.4 - adding stylesheet link tags
- 3.0.3 - fix error with semicolon separating links when should have been comma