Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

scrollbar-width

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scrollbar-width

Calculate the width of the scrollbar in a browser window

  • 3.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
25K
decreased by-3.44%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Credits

Thanks to olympicsoftware for the improved version (2.0+)

License

scrollbarWidth is licensed under the MIT license.

FAQs

Package last updated on 06 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc