Skip to content

Performance issue with multiple instances #2

Description

@IGx89

Hello! First off, I wanted to say how grateful I am for you making this plugin -- it's exactly what I've been looking for, a modern thumbnail scroller that functions well on mobile devices and in responsive layouts. Wanted to bring to your attention though a performance issue I've discovered: CPU usage gets progressively higher the more instances of the scroller there are on a page. I have a page with 15 of them and it completely pegs one of my CPU cores.

The issue appears to be with the 60ms setTimeout that the updateOnContentResize option (and a couple others) use. It uses about 3ms of CPU time on my machine every time it's called, and with 15 instances of the scroller that means there's hardly any time where the CPU isn't working.

Not sure what the best solution is, though for the moment I've changed the timeout from 60 to 600ms and that's brought my CPU usage down to ~5%. Not ideal, but good for now. I'm not super familiar with jQuery, but maybe there could be some resize event handlers you'd be able to use instead to get the same behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions