Responsive Edits
Every edit you save in the Visual Editor can be scoped to a viewport range. The snippet runtime checks the current window.innerWidth on each page load and only applies edits that match.
Viewport presets
The editor ships with four presets plus a custom range. Pick from the Viewport dropdown when editing an element.
- MOBILE — Applies when
window.innerWidth ≤ 767px. - TABLET — Applies when
window.innerWidthis between768pxand1023pxinclusive. - DESKTOP — Applies when
window.innerWidth ≥ 1024px. - ALL — Applies on every viewport. This is the default for new edits.
- CUSTOM(min, max) — A user-defined range. Set the minimum and maximum in pixels; either bound is optional.
How the runtime applies viewport-scoped edits
When the snippet runs, it evaluates each change against the current window width. Edits whose viewport scope matches are applied immediately. The runtime also listens for resize events and re-evaluates the change list, so rotating a phone or resizing a desktop window keeps the right edits active.
1function shouldApply(change, width) {2 switch (change.viewport) {3 case 'MOBILE':4 return width <= 7675 case 'TABLET':6 return width >= 768 && width <= 10237 case 'DESKTOP':8 return width >= 10249 case 'ALL':10 return true11 case 'CUSTOM':12 const { min, max } = change.viewportRange13 return (min == null || width >= min) && (max == null || width <= max)14 }15}Layering edits across viewports
You can save multiple edits to the same element with different viewport scopes. For example, you might want a short headline on mobile and a long one on desktop. The editor will create two separate changes — one scoped to MOBILE, one scoped to DESKTOP — and the runtime applies whichever matches the current width.
Previewing viewports
The editor's toolbar exposes four device modes: Desktop, Tablet, Mobile, and Custom. Desktop mode edits the live page directly. Tablet, Mobile, and Custom mount the customer URL inside a real iframe sized to the device viewport — media queries fire as they would on the actual device, touch detection behaves like the device, and window.innerWidth reports the iframe's dimensions rather than the host page's.
- Tablet renders an 820 × 1180 pixel canvas.
- Mobile renders a 390 × 844 pixel canvas.
- Custom exposes a width input — type any number between 320 and 4096 and the canvas resizes after a short debounce.
- The rotate button next to the segmented control swaps width and height, simulating landscape orientation.
Selection, edits, and saving all work the same way in iframe mode as in desktop mode. Edits captured against an element inside the iframe are persisted to the same change set; flipping back to Desktop replays them onto the live page.
While iframe mode is active, the AvsB extension strips frame-busting response headers (X-Frame-Options and the frame-ancestors directive of Content-Security-Policy) so even pages that normally refuse to be embedded will load. The header rewrite is scoped to the active tab and removed automatically when you flip back to Desktop or close the editor — every other tab in your browser is unaffected. You can audit what the extension is doing in real time at chrome://extensions → AvsB Dev Tools → details → View site permissions.
Related
- Selectors — pair viewport scoping with a stable selector for the most reliable test.
- Execution order — see where viewport evaluation sits in the snippet lifecycle.