Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7844783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:00:06+00:00 2026-06-02T17:00:06+00:00

DOMNodeInserted is known to make dynamic pages slow, MDN even recommends not using it

  • 0

DOMNodeInserted is known to make dynamic pages slow, MDN even recommends not using it altogether, but doesn’t provide any alternatives.

I’m not interested in the element inserted, I just need to know when some script modifies the DOM. Is there a better alternative to mutation event listeners (maybe getElementsByTagName inside an nsiTimer)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:00:10+00:00Added an answer on June 2, 2026 at 5:00 pm

    If you are creating a web app that targets recent mobile phones and newer versions of browsers (Firefox 5+, Chrome 4+, Safari 4+, iOS Safari 3+, Android 2.1+), you can use the following code to create an awesome event for the insertion of dom nodes, and it even runs on the nodes initially part of the page’s static mark-up!

    Here’s the link to the full post with and example: http://www.backalleycoder.com/2012/04/25/i-want-a-damnodeinserted/

    Note on Mutation Observers: while the newer Mutation Observers features in recent browsers are great for monitoring simple insertions and changes to the DOM, do understand that this method can be used to do far more as it allows you to monitor for any CSS rule match you can thing of. This is super powerful for many use-cases, so I wrapped this up in a library here: https://github.com/csuwildcat/SelectorListener

    You’ll need to add the appropriate prefixes to the CSS and animationstart event name if you want to target various browsers. You can read more about that in the post linked to above.

    The basic node insertion case

    CSS:

    @keyframes nodeInserted {  
        from {  
            outline-color: #fff; 
        }
        to {  
            outline-color: #000;
        }  
    }
    
    div.some-control {
        animation-duration: 0.01s;
        animation-name: nodeInserted;
    }
    

    JavaScript:

    document.addEventListener('animationstart', function(event){
        if (event.animationName == 'nodeInserted'){
            // Do something here
        }
    }, true);
    

    Listening for more complex selector matches:

    This enables things that are almost impossible to do with Mutation Observers

    CSS:

    @keyframes adjacentFocusSequence {  
        from {  
            outline-color: #fff; 
        }
        to {  
            outline-color: #000;
        }  
    }
    
    .one + .two + .three:focus {
        animation-duration: 0.01s;
        animation-name: adjacentFocusSequence;
    }
    

    JavaScript:

    document.addEventListener('animationstart', function(event){
        if (event.animationName == 'adjacentFocusSequence'){
            // Do something here when '.one + .two + .three' are 
            // adjacent siblings AND node '.three' is focused
        }
    }, true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

DOMNodeInserted event is called when the node be appended to, or be appended? I
I'm trying to listen for changes in a XML structure using Javascript. I've got
For sure this question is very easy, but I just cannot figure this out.
I'm trying to post-process content that is added to the DOM via the excellent
Error context: Visual Studio 2010 Service Pack 1 ASP.NET MVC 3 Application IE9 with
I need to use some data, calculated by JS (for example: window size) as
I'm attempting to embed the very convenient Google Translate translate element into a webpage,
I am writing a browser extension that needs to attach handlers to the keyup
I am applying an event listener function when elements are inserted into the document
I want to add an element after every like button (chrome extension). Since posts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.