Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialLeon Segal
14,754 PointsDOMContentLoaded is not firing
I only get the desired outcome when I use:
window.addEventListener('load', () => {
// code here
});
I am running ubuntu and using the latest firefox browser.
Anyone know why this is?
2 Answers
Tom Geraghty
24,174 Points97.67% of browsers support DOMContentLoaded according to CanIUse. Paste in your code and we'll see. Should be something like this:
<script>
document.addEventListener("DOMContentLoaded", function(event) {
console.log("DOM fully loaded and parsed");
});
</script>
Justin Hicks
14,290 PointsBubbling for this is supported by at least firefox Gecko 1.9.2 so if you have the latest then that shouldn't be an issue. Best advice I can supply you with is just look closely for a typo.