The browser uses the width of the window/viewport when switching between media queries, but it's important to remember that the scrollbar is additional space that's not included in the document width. If you're trying to match javascript changes to media query changes, you must include the 15px of scrollbar.