coderef

Visual viewport APIBaseline · Widely available

The visualViewport API provides a way to query and modify the user-visible viewport of a web page.

Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Aug 10, 2021. Widely available since Feb 10, 2024.

Browser support

DesktopChrome
1–60Not supported
61+Supportedsince Sep 5, 2017
Current: 155
Edge
12–18Not supported
79+Supportedsince Jan 15, 2020
Current: 154
Firefox
1–90Not supported
91+Supportedsince Aug 10, 2021
Current: 157
Safari
1–12.1Not supported
13+Supportedsince Sep 19, 2019
Current: 27
MobileChrome Android
18–60Not supported
61+Supportedsince Sep 5, 2017
Current: 155
Firefox Android
4–67Not supported
68+Supportedsince Jul 9, 2019
Current: 157
Safari iOS
1–12.2Not supported
13+Supportedsince Sep 19, 2019
Current: 27

How to use

This feature is Baseline widely available — use it freely, no fallback needed.

Example

Full syntax and examples are on MDN: VisualViewport.

Feature detection

JS · check before using
if ("VisualViewport" in globalThis) {
  // VisualViewport is available
} else {
  // load a polyfill or use a fallback
}

Sub-features

Support for each part of the feature (12). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
VisualViewport61799113616813
VisualViewport.height61799113616813
VisualViewport.offsetLeft61799113616813
VisualViewport.offsetTop61799113616813
VisualViewport.pageLeft61799113616813
VisualViewport.pageTop61799113616813
VisualViewport.resize_event62799113626813
VisualViewport.scale61799113616813
VisualViewport.scroll_event62799113626813
VisualViewport.scrollend_event126126150✕126150✕
VisualViewport.width61799113616813
Window.visualViewport61799113616813