Skip to content

Instantly share code, notes, and snippets.

@Zirak
Created July 27, 2022 11:02
Show Gist options
  • Save Zirak/d79d46a545274fee00b6d4c386e07a7d to your computer and use it in GitHub Desktop.
Save Zirak/d79d46a545274fee00b6d4c386e07a7d to your computer and use it in GitHub Desktop.
require('http').createServer((req, res) => {
if (req.url === '/1.js') {
setTimeout(() => {
res.write('console.log(1);');
res.end();
}, 10000);
}
if (req.url === '/2.js') {
res.write('console.log(2);');
res.end();
}
if (req.url === '/') {
res.write(`
<body></body>
<script>
function loadScript(src) {
let scr = document.createElement('script');
scr.src = src;
document.body.appendChild(scr);
}
loadScript('./1.js');
loadScript('./2.js');
</script>
`);
res.end();
}
}).listen(8000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment