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 trial
Christopher Stuart
Full Stack JavaScript Techdegree Graduate 27,771 PointsIs there any advantage to using DomContentLoaded listener?
I see that Guil actually changed back to loading the javascript at the end of the page when this video was complete...so is there any reason I would ever even use this event listener?
2 Answers
Steven Parker
243,318 PointsAccording to the MDN page, "The DOMContentLoaded event is fired when the initial HTML document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading." This might be useful if you're doing something that requires the script code to start a bit earlier than it would by just placing it at the bottom.
But I think it's safe to say that if you don't know you need it, you almost certainly don't.
Christopher Stuart
Full Stack JavaScript Techdegree Graduate 27,771 Pointscool thanks Steven