One of the most popular scripts on this blog is the gallery and slideshow plugin. Based on user feedback and my own experience using it in projects, I've made a significant round of updates.
The biggest change — code optimization:
The plugin was essentially rewritten. Code was reduced from 5.5 KB to 3.5 KB (then grew back to ~5 KB with new parameters), but more importantly the algorithm was overhauled to reduce browser load significantly.
Bug fixes:
- Fixed a bug with the pause function conflicting with slide transitions
- Fixed edge cases when prev/next links pointed to non-existent slides
- Renamed parameter
numElementLinktonumElementfor consistency
New parameters:
- noCicle — disable cyclic slide switching (slideshow stops at the last slide)
- disableClass — CSS class to apply to prev/next buttons when disabled (at the first or last slide when noCicle is active)
These additions make the plugin much more flexible for real-world use cases where you don't want an infinite loop.
Please report any bugs in the comments — I read everything.