Reputation: 8284
I am trying to debug an element that loads about for the first .5 - 1 second on page load. It completely disappears after that; I am wondering if there is any way at all I can stop the page while it's loading at a certain time, either with a script or emulator so I can track down this element with developer tools.
Upvotes: 2
Views: 3804
Reputation: 15445
Second attempt, now that I understand your question a little better.
You can use a MutationObserver
to output changes to the DOM. Something as simple as
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
console.log(mutation);
});
})
observer.observe(document.body, {
attributes: true,
childList: true,
characterData: true,
subtree: true
});
var hiders = document.querySelectorAll('.hider'),
hiders = Array.prototype.slice.call(hiders);
hiders.forEach(function(el) {
el.parentNode.removeChild(el);
});
<div class="hider"></div>
<div class="hider"></div>
in the window's load
handler will work, and will output a MutationRecord
on each change. I'd bet one of those will be your element (specifically, the removedNodes
of the record.) The browser console for this snippet will have what you'll see if you use this.
Upvotes: 1
Reputation: 29999
You can call window.stop()
to stop window loading, if that is what you are looking for.
It sounds like it would be easier to pause the script execution with the browsers javascript debugger though, by setting some breakpoints instead of manually inserting a stop statement.
Upvotes: 2