Skip to content

Instantly share code, notes, and snippets.

@stormbreakers
Forked from AllThingsSmitty/readyState.js
Created March 8, 2016 10:34
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 stormbreakers/e15ce9a1dd08107d54ea to your computer and use it in GitHub Desktop.
Save stormbreakers/e15ce9a1dd08107d54ea 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