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:
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.