skip to content

Getting the Scrollbar Width

1 min read

I’ve been asked a few times if Dimensions would provide a method for getting the scrollbar width. In Dimensions 1.0 I created an internal method for finding the scrollbar width to hack around some browser limitations. I eventually found other ways around those limitations and that code is no longer in Dimensions. I know that in some unusual cases it can be useful, so I want to go ahead and provide that code as one of my jQuery snippets. It is just a single method added to the jQuery namespace called getScrollbarWidth.

$.getScrollbarWidth();

Here is an example of it and here is the small script.