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

121
Views
WP Rocket will cause click event being fired twice

I find a strange issue. When enable WP Rocket, the first time when I click the menu in the mobile version, the click event will be fired twice:

    function addEventListenerToElement(element, type, listener)
    {
        if (element) {
            element.addEventListener(type, listener);
        }
    }

    addEventListenerToElement(document.querySelector('.menu-toggle'), "click", function(event) {
        // Slide toggle main menu for mobile version
        DOMAnimations.slideToggle(document.querySelector('.mobile-nav'), 500);
        
        // Prevent the default action, such as follow a hyperlink
        event.preventDefault();
        
        // Prevent the current event from further propagation to outer DOM nodes
        event.stopPropagation();         
    
        //  2021-10-21: The following return false can be commented out since:
        //  1. addEventListener callback function does not need to return a value, see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#the_event_listener_callback
        //  2. It is equivalent to event.preventDefault() + event.stopPropagation(). See https://stackoverflow.com/a/11184286/2704265
        //  We will not add comments for the following similar cases.
        //  return false;
    });

I perform the following test:

  1. When the page is first loaded in mobile phone, and I click the menu, the menu will slide down and the up again. And by adding the breakpoint at DOMAnimations.slideToggle, I find the event is fired twice. The next time when I click the menu, then the event will only be executed once.
  2. If disable WP Rocket, then the event will only be fired once.

Has any one encountered similar issues?

Update

The website with WP Rocket enabled can be found at https://www.datanumen.com

The website with WP Rocket disabled can be found at http://www.sybase-recovery.com

The two sites use the same JavaScript code.

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!