Created
April 5, 2019 08:45
-
-
Save ohze/064d81a0c7c9565f58f9bcac36ff3d22 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/qomesat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
addListener = function(obj, eventType, listener) { | |
obj.addEventListener(eventType, listener, false); | |
}; | |
// Wait for document to load before initializing | |
var docReady = false; | |
var loadHandler = function(e) { | |
/*log.info*/console.log("loadHandler triggered by " + (e ? e.type + " event" : "document already loaded")); | |
if (!docReady) { | |
docReady = true; | |
console.log('init()'); | |
} | |
}; | |
// Test whether the document has already been loaded and initialize immediately if so | |
if (document.readyState == "complete") { | |
loadHandler(); | |
} else { | |
document.addEventListener("DOMContentLoaded", loadHandler, false); | |
// Add a fallback in case the DOMContentLoaded event isn't supported | |
addListener(window, "load", loadHandler); | |
} | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">addListener = function(obj, eventType, listener) { | |
obj.addEventListener(eventType, listener, false); | |
}; | |
// Wait for document to load before initializing | |
var docReady = false; | |
var loadHandler = function(e) { | |
/*log.info*/console.log("loadHandler triggered by " + (e ? e.type + " event" : "document already loaded")); | |
if (!docReady) { | |
docReady = true; | |
console.log('init()'); | |
} | |
}; | |
// Test whether the document has already been loaded and initialize immediately if so | |
if (document.readyState == "complete") { | |
loadHandler(); | |
} else { | |
document.addEventListener("DOMContentLoaded", loadHandler, false); | |
// Add a fallback in case the DOMContentLoaded event isn't supported | |
addListener(window, "load", loadHandler); | |
} | |
</script></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addListener = function(obj, eventType, listener) { | |
obj.addEventListener(eventType, listener, false); | |
}; | |
// Wait for document to load before initializing | |
var docReady = false; | |
var loadHandler = function(e) { | |
/*log.info*/console.log("loadHandler triggered by " + (e ? e.type + " event" : "document already loaded")); | |
if (!docReady) { | |
docReady = true; | |
console.log('init()'); | |
} | |
}; | |
// Test whether the document has already been loaded and initialize immediately if so | |
if (document.readyState == "complete") { | |
loadHandler(); | |
} else { | |
document.addEventListener("DOMContentLoaded", loadHandler, false); | |
// Add a fallback in case the DOMContentLoaded event isn't supported | |
addListener(window, "load", loadHandler); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment