1if( document.readyState !== 'loading' ) {
2 console.log( 'document is already ready, just execute code here' );
3 myInitCode();
4} else {
5 document.addEventListener('DOMContentLoaded', function () {
6 console.log( 'document was not ready, place code here' );
7 myInitCode();
8 });
9}
10
11function myInitCode() {}