Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What might make click events slow to fire?

For some reason, click events on my live server take significantly longer to fire than on my local development machine. For example, here's some basic code I used as a test:

jQuery(document).ready(function(){
    jQuery('a[rel^="foxyLightbox"]').on("click", function(e) {
        console.log("HA!");
        return false;
    });
});

When I run that locally and click on links, the text prints out to the console pretty much instantaneously. If I click it a bunch of times in a row, there's no lag whatsoever.

When I run it on my live server, there's almost exactly a one second delay before the event fires. If I click it a bunch of times in a row, then there is lag and it prints out about once a second.

Here's a live example page: https://www.foxytronics.com/products/68-springrc-sm-s4303r-continuous-rotation-servo

The link that triggers the event is the large product image in the upper right.

At first I thought the issue was my javascript code, but then I commented it out and used the test code above (which is extremely short), so that can't be it. What could be delaying the click event from firing?

like image 738
Nate Avatar asked Dec 13 '13 01:12

Nate


People also ask

Which events will be fired on click on HTML element?

The HTMLElement. click() method simulates a mouse click on an element. When click() is used with supported elements (such as an <input> ), it fires the element's click event. This event then bubbles up to elements higher in the document tree (or event chain) and fires their click events.

How do I delay onclick event?

No, but your function can set a timer event for whatever delay you want to handle it later.

How do you check an event is firing?

Open Google Chrome and press F12 to open Dev Tools. Go to Event Listener Breakpoints, on the right: Click on the events and interact with the target element. If the event will fire, then you will get a breakpoint in the debugger.


1 Answers

I used chrome dev tools and I see that you have strange long mouseDown event handler:

long mouse down event handler

Some work is performed in JS script from static.getclicky.com

like image 70
Tony Avatar answered Oct 13 '22 19:10

Tony