Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
B

better-scroll

> 前端框架
Open source

:scroll: inspired by iscroll, and it supports more features and has a better scroll perfermance

16.5K stars0 likes0 views
WebsiteGitHub

About

:scroll: inspired by iscroll, and it supports more features and has a better scroll perfermance

better-scroll

中文文档

1.x Docs

2.x Docs

2.x Demo

Note: 1.x is not maintained. please migrate your version as soon as possible

Install

bash
npm install better-scroll -S # install 2.x,with full-featured plugin.

npm install @better-scroll/core # only CoreScroll
javascript
import BetterScroll from 'better-scroll'

let bs = new BetterScroll('.wrapper', {
  movable: true,
  zoom: true
})

import BScroll from '@better-scroll/core'

let bs = new BScroll('.wrapper', {})

CDN

BetterScroll with full-featured plugin.

xml
<script src="https://unpkg.com/better-scroll@latest/dist/better-scroll.js"></script>

<script src="https://unpkg.com/better-scroll@latest/dist/better-scroll.min.js"></script>
javascript
let wrapper = document.getElementById("wrapper")
let bs = BetterScroll.createBScroll(wrapper, {})

Only CoreScroll

xml
<script src="https://unpkg.com/@better-scroll/core@latest/dist/core.js"></script>

<script src="https://unpkg.com/@better-scroll/core@latest/dist/core.min.js"></script>
javascript
let wrapper = document.getElementById("wrapper")
let bs = new BScroll(wrapper, {})

What is BetterScroll ?

BetterScroll is a plugin which is aimed at solving scrolling circumstances on the mobile side (PC supported already). The core is inspired by the implementation of iscroll, so the APIs of BetterScroll are compatible with iscroll on the whole. What's more, BetterScroll also extends some features and optimizes for performance based on iscroll.

BetterScroll is implemented with plain JavaScript, which means it's dependency free.

Getting started

The most common application scenario of BetterScroll is list scrolling. Let's see its HTML:

xml

In the code above, BetterScroll is applied to the outer wrapper container, and the scrolling part is content element. Pay attention that BetterScroll handles the scroll of the first child element (content) of the container (wrapper) by default, which means other elements will be ignored. However, for BetterScroll v2.0.4, content can be specified through the specifiedIndexAsContent option. Please refer to the docs for details.

The simplest initialization code is as follow:

javascript
import BScroll from '@better-scroll/core'
let wrapper = document.querySelector('.wrapper')
let scroll = new BScroll(wrapper)

BetterScroll provides a class whose first parameter is a plain DOM object when instantiated. Certainly, BetterScroll inside would try to use querySelector to get the DOM object.

The principle of scrolling

Many developers have used BetterScroll, but the most common problem they have met is:

I have initiated BetterScroll, but the content can't scroll.

The phenomenon is 'the content can't scroll' and we need to figure out the root cause. Before that, let's take a look at the browser's scrolling principle: everyone can see the browser's scroll bar. When the height of the page content exceeds the viewport height, the vertical scroll bar will appear; When the width of page content exceeds the viewport width, the horizontal bar will appear. That is to say, when the viewport can't display all the content, the browser would guide the user to scroll the screen with scroll bar to see the rest of content.

The principle of BetterScroll is samed as the browser. We can feel about this more obviously using a picture:

The green part is the wrapper, also known as the parent container, which has fixed height. The yellow part is the content, which is the first child element of the parent container and whose height would grow with the size of its content. Then, when the height of the content doesn't exceed the height of the parent container, the content would not scroll. Once exceeded, the content can be scrolled. That is the principle of BetterScroll.

Plugins

Enhance the ability of BetterScroll core scroll through plugins, such as

javascript
import BScroll from '@better-scroll/core'
import PullUp from '@better-scroll/pull-up'

let bs = new BScroll('.wrapper', {
  pullUpLoad: true
})

Please see for details, Plugins.

Using BetterScroll with MVVM frameworks

I wrote an article When BetterScroll meets Vue (in Chinese). I also hope that developers can contribute to share the experience of using BetterScroll with other frameworks.

A fantastic mobile ui lib implement by Vue: cube-ui

Contributing

Online one-click setup

You can use Gitpod(An Online Open Source VS Code like IDE which is free for Open Source) for contributing. With a single click it will launch a workspace and automatically:

  • clone the better-scroll repo.
  • install all of the dependencies.
  • run yarn vue:dev,
  • run yarn docs:build and yarn docs:dev.

Using BetterScroll in the real project

If you want to learn how to use BetterScroll in the real project,you can learn my two practical courses(in Chinese)。

High imitating starvation takeout practical course base on Vue.js

Project demo address

Music App advanced practical course base on Vue.js

Project demo address

Issues· 72 open

View all issuesOpen on GitHub
  • #1385

    嵌套横纵向 Scroller 情况下,当内部的 Scroller 的不满足滚动条件时,会阻止外部纵向的 Scroller 滚动

    Updated Apr 28, 2026
  • #1384

    【严重】已经有3年没更新了,存在老旧化问题,软件进入衰退期等,期望发布新版本刷一下存在感,不然只能被时代淘汰了。

    Updated Apr 1, 2026
  • #1383

    Prototype Pollution in @better-scroll/shared-utils

    Updated Mar 26, 2026
  • #1365

    当启用 click: true 配置派发事件时无法区分是左键点击还是右键点击

    Updated Dec 25, 2025
  • #1382

    scrollbar插件的滚动条在受到scale影响时,滑动滑块和点击滚动条移动的距离不正确

    Updated Dec 22, 2025
  • #1377

    [New Feature] 期望有办法监听 给原生滚动

    Updated Dec 22, 2025
  • #1353

    使用macbook的触控板滑动内容,滚动过程会一直抖动

    Updated Nov 19, 2025
  • #1284

    手势缩放时,在部分手机端的浏览器上,放大时页面会空白

    Updated Jun 11, 2025
  • #1381

    微信跳转标签初始成功后,无法触发滚动了

    Updated Apr 23, 2025
  • #1380

    [New Feature] 可以发布一个新版本吗?

    Updated Jan 9, 2025

> Tags

TypeScriptbetter-performanceiosiscrollmobile-web

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 1, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架