Waiting for window load event in README examples
callumlocke opened this issue · 2 comments
callumlocke commented
function handleImageFail() {
this.style.display = 'none';
}
window.addEventListener('load', function() {
var delegate = new Delegate(document.body);
delegate.on('error', 'img', handleImageFail);
}, false);
Is there a reason to wait for the window load event here? Doesn't it mean that any image errors (from img's in the HTML) will have already been dispatched and missed before the delegate starts listening for them?
RangerMauve commented
I think the reason that the example does that is that there needs to be a document.body
for domdelegate to even be able to start listening, and that might not be available before the load event.
orangemug commented
I believe @callumlocke is correct, we updated this to wait on DOMContentLoaded
in PR #83. Closing issue please reopen if you have any further comments.