Skip to content

Instantly share code, notes, and snippets.

@TimothyGu TimothyGu/index.js
Created Jul 11, 2018

Embed
What would you like to do?
Firefox #1475000
"use strict";
const http = require("http");
const server = http.createServer((req, res) => {
if (req.url.includes("slow.js")) {
setTimeout(() => {
res.setHeader("Content-Type", "text/javascript");
res.end("void 0;");
}, 5000);
} else {
res.statusCode = 404;
res.setHeader("Content-Type", "text/plain");
res.end("Not found");
}
});
server.listen(8888);
<p>This should get erased.</p>
<button onclick="document.open();">document.open()</button>
<script src="http://localhost:8888/slow.js"></script>
<script>
alert("You were too slow! Hit stop before this message.");
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.