Skip to content

Instantly share code, notes, and snippets.

@james2doyle
Forked from AllThingsSmitty/readyState.js
Created March 8, 2016 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save james2doyle/ceb52c0b4b7f7e77f816 to your computer and use it in GitHub Desktop.
Save james2doyle/ceb52c0b4b7f7e77f816 to your computer and use it in GitHub Desktop.
Using readyState to show document state
// credit: Louis Lazaris
document.onreadystatechange = function () {
switch (document.readyState) {
case 'loading':
console.log('loading...');
break;
case 'interactive':
console.log('DOM is ready...');
break;
case 'complete':
console.log('Document complete...');
break;
}
};
// https://jsbin.com/diyihu/edit?html,css,js,console,output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment