iscroll
Smooth scrolling for the web
A tiny 4KB JavaScript library that adds smooth, customizable scrolling to web pages and mobile apps, with separate variants for zooming, real-time position tracking, and memory-efficient infinite lists.
iScroll is a small JavaScript library that adds smooth scrolling to web pages and apps, particularly on mobile devices where browser scrolling has historically been slow or limited. When you have a list, a photo gallery, or any scrollable area inside a web page, iScroll can control how that content moves when a user swipes or drags across it.
The library weighs about 4 kilobytes, works without depending on any other library, and runs across a wide range of devices including older Android phones, iPhones, and desktop browsers. It does not just replicate native scrolling; it adds extra control that browsers do not normally expose. Developers can read the exact scroll position at any moment, hook into events that fire before and after scrolling, and set custom animation curves for how content decelerates after a swipe.
The project ships in several versions so you can pick the one that fits your use case. The standard version covers most situations. A stripped-down lite version is the smallest and fastest option for pages that only need basic mobile scrolling. A probe version is optimized for reading the scroll position in real time during movement. A zoom version adds pinch-to-zoom on top of scrolling. An infinite version handles very long lists efficiently by recycling elements in memory rather than loading everything at once.
To use iScroll you wrap the scrollable content in a container element in your HTML, then pass that container to the iScroll constructor in JavaScript. Configuration options control things like whether a scrollbar appears, whether the mouse wheel works, and which CSS technique the engine uses internally.
The readme is a detailed technical guide written for web developers. It covers initialization, configuration options, events, and known limitations with certain CSS properties. The full README is longer than what was shown.
Where it fits
- Add smooth touch-scrolling to a mobile web app content area that the device browser cannot natively scroll.
- Build a memory-efficient infinite-scroll list that recycles DOM elements so thousands of items stay fast.
- Add pinch-to-zoom to an image gallery or map on a mobile web page using the iScroll zoom variant.
- Read the exact scroll position in real time during a swipe gesture to drive a parallax effect or custom progress bar.