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: 155Edge
12–18Not supported
79+Supportedsince Jan 15, 2020
Current: 154Firefox
1–90Not supported
91+Supportedsince Aug 10, 2021
Current: 157Safari
1–12.1Not supported
13+Supportedsince Sep 19, 2019
Current: 27MobileChrome Android
18–60Not supported
61+Supportedsince Sep 5, 2017
Current: 155Firefox Android
4–67Not supported
68+Supportedsince Jul 9, 2019
Current: 157Safari iOS
1–12.2Not supported
13+Supportedsince Sep 19, 2019
Current: 27How 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
}Documentation (MDN)
Specification
Sub-features
Support for each part of the feature (12). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| VisualViewport | 61 | 79 | 91 | 13 | 61 | 68 | 13 |
| VisualViewport.height | 61 | 79 | 91 | 13 | 61 | 68 | 13 |
| VisualViewport.offsetLeft | 61 | 79 | 91 | 13 | 61 | 68 | 13 |
| VisualViewport.offsetTop | 61 | 79 | 91 | 13 | 61 | 68 | 13 |
| VisualViewport.pageLeft | 61 | 79 | 91 | 13 | 61 | 68 | 13 |
| VisualViewport.pageTop | 61 | 79 | 91 | 13 | 61 | 68 | 13 |
| VisualViewport.resize_event | 62 | 79 | 91 | 13 | 62 | 68 | 13 |
| VisualViewport.scale | 61 | 79 | 91 | 13 | 61 | 68 | 13 |
| VisualViewport.scroll_event | 62 | 79 | 91 | 13 | 62 | 68 | 13 |
| VisualViewport.scrollend_event | 126 | 126 | 150 | ✕ | 126 | 150 | ✕ |
| VisualViewport.width | 61 | 79 | 91 | 13 | 61 | 68 | 13 |
| Window.visualViewport | 61 | 79 | 91 | 13 | 61 | 68 | 13 |