3

I've got an html page that, after a certain amount of time, has a particular element being removed or deleted from the DOM.

The element is a div with the id "workspace".

There are lots of third party scripts being loaded in the page, and after some time, the "workspace" element is being removed, but I'm not sure why.

How can I determine which javascript library is removing the "workspace" element?

2
  • 1
    Insert console.log statements everywhere. Commented Jan 15, 2013 at 13:38
  • Try using firebug or chrome developer tools. You can do a step by step debug.
    – Searock
    Commented Jan 15, 2013 at 13:41

2 Answers 2

6

If you are using chrome, you can go to the elements tab, right click on the element (before it is deleted) and click break on... -> subtree modifications. This should break the javascript right as this element is being altered.

1
  • This is the best way I know of to do this. Much better than using console.log, assuming you can add the breakpoint in time. Commented Jan 15, 2013 at 13:42
1

Use Chrome, and find the element in the "Elements" inspector.

  • If you can see the element, right click on it, and choose "Inspect Element".
  • If you can't see the element, Bring up the "Elements" inspector by selecting the following in the menu:

    View | Developer | Developer Tools

Right click on the element's name or node in the "Elements" inspector, and select the following in the pop up menu:

  • Break on | Node Removal

Now the debugger will kick in when the item gets removed!

5
  • 2
    You couldn't have just edited my post? It's clear that I gave you the information you needed. Commented Jan 15, 2013 at 13:46
  • I was answering my own question, but submitted my question first, by mistake. If you'd like, I could totally edit your question, and delete my answer...
    – Brad Parks
    Commented Jan 15, 2013 at 14:02
  • Yeah, I did.... I needed to know this yesterday, Googled it, and didn't see any results. A guy at work here told me how to do it.... So I thought I'd post it on SO so it would be findable by someone else. So I went to ask and answer the question (which you can do in one step on SO) but I hit "Enter" by mistake and the question submitted. So I just hit "Answer" right off, submitted my answer, and you'd answered while I answered ;-) I left mine because I detailed the steps a bit more, but I have no problem editing your answer if you'd prefer! Thanks for answering!
    – Brad Parks
    Commented Jan 15, 2013 at 14:19
  • No, if you meant to do it that way, it's fine. I love that stack overflow is so fast that a mistake like that can result in someone (me) sniping your answer. Commented Jan 15, 2013 at 14:22
  • Yeah.... I'll admit I was surprised that it was answered so quickly! and thanks again for the answer. I'll upvote yours, and leave mine here as well. Thanks!
    – Brad Parks
    Commented Jan 15, 2013 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.