I have been having trouble getting this plugin to attach correctly to ajax loaded elements, and I haven't been able to figure out the reason they sometimes get attached, and sometimes don't. but only for this particular plugin. So my question is, would having a setInterval run something like every 300 milliseconds, or so cause the browser to become sluggish over time if it's just attaching a jquery plugin to certain elements that may or not be on the page.
what I have initially tried doing is:
however it's not attaching it (all the way anyways, some parts are being changed, but not the main plugin)
However, when I call another ajax event, and trigger the same thing in that callout, it attaches it to this element, and the other element.
The setInterval function adds it to them all as well.
In a general sense a 300ms interval isn't a problem; obviously it's what you try to run each interval that might be a problem. And using interval on all ".nano" elements will re-apply .nanoScroller() even to previously processed elements, so that's not terribly efficient. I'd suggest looking more at why your Ajax success code doesn't do it.
以上就是jQuery setInterval every 300 milliseconds, too much load on browser?的详细内容，更多请关注web前端其它相关文章！