Created
June 5, 2019 13:01
-
-
Save yeromin/adf83e102998e6cfdcedcf99a11b220e to your computer and use it in GitHub Desktop.
onload
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
window.addEventListener('DOMContentLoaded', function() { | |
console.log('window - DOMContentLoaded - capture'); // 1st | |
}, true); | |
document.addEventListener('DOMContentLoaded', function() { | |
console.log('document - DOMContentLoaded - capture'); // 2nd | |
}, true); | |
document.addEventListener('DOMContentLoaded', function() { | |
console.log('document - DOMContentLoaded - bubble'); // 2nd | |
}); | |
window.addEventListener('DOMContentLoaded', function() { | |
console.log('window - DOMContentLoaded - bubble'); // 3rd | |
}); | |
window.addEventListener('load', function() { | |
console.log('window - load - capture'); // 4th | |
}, true); | |
document.addEventListener('load', function(e) { | |
/* Filter out load events not related to the document */ | |
if(['style','script'].indexOf(e.target.tagName.toLowerCase()) < 0) | |
console.log('document - load - capture'); // DOES NOT HAPPEN | |
}, true); | |
document.addEventListener('load', function() { | |
console.log('document - load - bubble'); // DOES NOT HAPPEN | |
}); | |
window.addEventListener('load', function() { | |
console.log('window - load - bubble'); // 4th | |
}); | |
window.onload = function() { | |
console.log('window - onload'); // 4th | |
}; | |
document.onload = function() { | |
console.log('document - onload'); // DOES NOT HAPPEN | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment