Skip to content

Instantly share code, notes, and snippets.

@codepunkt
Last active December 11, 2015 11:48
Show Gist options
  • Save codepunkt/4596410 to your computer and use it in GitHub Desktop.
Save codepunkt/4596410 to your computer and use it in GitHub Desktop.
Delay DOMContentLoaded. NodeJS server using connect to deliver 25s delayed css.
<!doctype html5>
<html>
<head>
<style>
#box { height: 250px; -webkit-transition: all 5s; -moz-transition: all 5s; }
</style>
<script>
window.addEventListener('DOMContentLoaded', function() {
console.log('DOMContentLoaded!');
}, false);
window.setTimeout(function() {
console.log('Changing color...');
document.getElementById('box').style.backgroundColor = '#bada55';
}, 5000);
</script>
</head>
<body>
<div id="box"></div>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/delay25s.css"/>
<script src="whatever.js"></script>
</body>
</html>
require('connect')().use(function(req, res) {
setTimeout(function() {
res.end('body { background: #eee; }');
}, 25000); }
).listen(8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment