# scrollbar-width

> Calculate the width of the scrollbar in a browser window

Latest version **3.1.1** (published 2015-05-06) · 0 weekly downloads

## Install

```sh
npm install scrollbar-width
pnpm add scrollbar-width
yarn add scrollbar-width
bun add scrollbar-width
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.1 |
| Published | 2015-05-06 |
| First published | 2014-09-10 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Maintainers | olmokramer |

## Links

- npm: https://www.npmjs.com/package/scrollbar-width
- Repository: https://github.com/olmokramer/scrollbar-width.js
- Homepage: https://github.com/olmokramer/scrollbar-width.js#readme
- Issues: https://github.com/olmokramer/scrollbar-width.js/issues
- npm.io page: https://npm.io/package/scrollbar-width

## Recent versions

- 3.1.1 (latest) — 2015-05-06
- 1.0.2 (1.0.2) — 2014-09-10
- 1.0.1 (1.0.1) — 2014-09-10
- 1.0.0 (1.0.0) — 2014-09-10
- 3.1.0 — 2015-05-06
- 3.0.0 — 2015-01-21
- 2.0.2 — 2014-12-10
- 2.0.1 — 2014-11-19
- 2.0.0 — 2014-11-14
- 1.0.7 — 2014-09-13
- 1.0.6 — 2014-09-12
- 1.0.5 — 2014-09-11
- 1.0.4 — 2014-09-11
- 1.0.3 — 2014-09-10

## README

# [scrollbar-width.js](https://github.com/olmokramer/scrollbar-width.js) 3.0.0

scrollbar-width.js is a library for calculating the scrollbar size of a browser window. It is compatible with AMD, CommonJS and the standard browser environment.

## Installation/Usage

### AMD

Usage with AMD is straightforward:

```
require([
  'js/scrollbar-width'
], function(calcScrollbarWidth) {
  var scrollbarWidth = calcScrollbarWidth();
  // ...
});
```

### Node.js

Install with npm:

```
npm install scrollbar-width
```

Then require it and call the function:

```
var scrollbarWidth = require("scrollbar-width")();
```

### Bower

To install with Bower run:

```
bower install scrollbar-width.js
```

### Browser

Include it in your HTML:

```
<script src="js/scrollbar-width.js"></script>
```

Then just call the function:

```
var scrollbarWidth = window.getScrollbarWidth();
```

## Notes

### Cached value

The function will cache the value it has calculated. You can force to calculate again by calling it with it's first parameter set to `true`:

```
var newScrollbarWidth = calcScrollbarWidth(true);
```

### scrollbarWidth() returns null

Until the document is loaded (document.readyState !== 'loading'), scrollbarWidth() will return null. So be sure to call it when the document has loaded.

## Compatibility

Tested in and compatible with:
- Chrome
- FireFox
- Opera
- IE (tested in 8+)

## Issues

If you find any issues, please file an issue on the
[github page](https://github.com/olmokramer/scrollbar-width.js/issues).

## Credits

Thanks to [olympicsoftware](https://github.com/olympicsoftware) for the improved version (2.0+)

## License

scrollbarWidth is licensed under the [MIT license](LICENSE).

---
_Source: https://npm.io/package/scrollbar-width · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
