- Download
package.json
andsingle-preload.js
and put into same folder - Run
npm install
- Run
node single-preload.js
- Visit
http://127.0.0.1:4000/
using Safari Technology Preview 24 with the Link Preload experimental feature activated - Check the
Network
tab of the web development tools. See twostyle.css
that's loaded
Created
February 22, 2017 19:29
-
-
Save voxpelli/0927bb9d53d027d924728ed7382c2fb6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "preload-testcase", | |
"version": "1.0.0", | |
"description": "", | |
"main": "single-preload.js", | |
"author": "Pelle Wessman <pelle@kodfabrik.se> (http://kodfabrik.se/)", | |
"license": "MIT", | |
"dependencies": { | |
"express": "^4.14.1" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const app = require('express')(); | |
app.get('/style.css', (req, res) => { | |
res.type('css'); | |
res.send('body { background: blue; }') | |
}); | |
app.get('/', (req, res) => { | |
res.set('Link', '</style.css>; rel=preload; as=style'); | |
res.send(`<!DOCTYPE html> | |
<html id="root-element" class="no-js"> | |
<head> | |
<meta charset="utf-8" /> | |
<link rel="stylesheet" href="/style.css" /> | |
</head> | |
<body> | |
<h1>Single preload</h1> | |
<p>Test case to detect double loading resource through rel-preload</p> | |
</body> | |
</html> | |
`); | |
}); | |
app.listen(4000, function () { | |
console.log('Example app listening on port 4000!') | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment