Skip to content

Instantly share code, notes, and snippets.

@mrmartineau mrmartineau/index.js
Created Aug 26, 2015

What would you like to do?
Better DOMready
// This is needed to prevent onreadystatechange being run twice
var ready = false;
document.onreadystatechange = function() {
if (ready) {
// interactive = DOMContentLoaded & complete = window.load
if (document.readyState == 'interactive' || document.readyState == 'complete') {
ready = true;
// init you code here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.