Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

122
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda