最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What might make click events slow to fire? - Stack Overflow

programmeradmin4浏览0评论

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:

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 mented 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?

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./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 mented 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?

Share Improve this question edited Dec 13, 2013 at 1:52 Nate asked Dec 13, 2013 at 1:45 NateNate 28.6k39 gold badges136 silver badges228 bronze badges 2
  • @C.S. My bad, the large picture. If you open your console and then click it, you'll see that there's about a one second delay between the click and the text printing out. Then if you click multiple times, there's a delay between each time it prints out. – Nate Commented Dec 13, 2013 at 1:51
  • When you test locally, did you test only the html file that uses that script, like having an html page with only the thumbnail and the js? or did you test it as it would appear on the website, pleted, but just locally? – C. S. Commented Dec 13, 2013 at 1:59
Add a ment  | 

1 Answer 1

Reset to default 5

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

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

发布评论

评论列表(0)

  1. 暂无评论