Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
MutationObserver not working if tab not focused

I am working on a chrome extension and i have a problem with MutationObserver, not sure if i am missing something or it's the normal behavior. The observer works when i am on the chrome tab which uses the mutation i receive messages when changes happens normal, but when i am not on tab, either i am on another tab or another window nothing happens until i comeback to the tab where i use mutation.

exemple let's say i use stackoverflow.com on a tab where i observe mutation all good i get the changes then i keep my tab open and i switch to another tab, the mutations stopped working like if the dom doesn't update when i am on another tab till i comeback.

window.onload = () => {


  console.log("init observer");

  let mutationBinaryObserver = new MutationObserver(function (mutations) {
    mutations.forEach(function (mutation) {
      if (
        mutation.target &&
        mutation.target.className &&
        typeof mutation.target.className === "string" &&
        mutation.target.className.indexOf("dialog-subtitle-badge") >= 0
      ) {
        getChatMessages();
      }
    });
  });
});

Thanks for your help and advice, my goal is to be using my computer and receiving updates from a tab on chrome even if i am not focusing it.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!