Skip to content

Instantly share code, notes, and snippets.

@eiriklv
Forked from matthewdfuller/slowdown.js
Created May 9, 2014 12:40
Show Gist options
  • Save eiriklv/c94ab478df2006f801a4 to your computer and use it in GitHub Desktop.
Save eiriklv/c94ab478df2006f801a4 to your computer and use it in GitHub Desktop.
var SPEED = 40;
var TEXT = 'Site loading slowly? Without net neutrality, this could become the norm. Learn more at <a href="http://www.theopeninter.net/">theopeninter.net/</a>.'
var overlay = document.createElement('div');
overlay.innerHTML = '<p>' + TEXT + '</p>';
var docHeight = document.body.scrollHeight;
overlay.style.display = 'block';
overlay.style.position = "fixed";
overlay.style.left = "0px";
overlay.style.bottom = "0px";
overlay.style.zIndex = "100";
overlay.style.backgroundColor = 'white';
overlay.style.width="100%";
overlay.style.height = docHeight + "px";
overlay.style.textAlign = "center";
overlay.style.padding = "30px";
overlay.style.fontFamily = "sans-serif";
document.body.appendChild(overlay);
var newHeight = docHeight;
var interval = window.setInterval(function(){
newHeight = newHeight - 5;
overlay.style.height = newHeight + "px";
overlay.style.bottom = "0px";
if (newHeight < 1) {
clearInterval(interval);
}
}, SPEED);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment