Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To preserve a meaningful scroll position, first decide whether you need the same pixel offset or the same content item to remain in view. Use the browser’s native history restoration for back/forward navigation, CSS scroll anchoring for ordinary layout shifts, and application-managed restoration when your capture must return to a particular item. A ResizeObserver can signal that an element changed size, but it cannot by itself determine that a page is ready to capture.

Choose what “the same position” means

Dynamic pages can add content, resize images, or update components after a user or capture script has scrolled. Those changes can move the content that was visible. There are three different goals:

  • Same document coordinate: return to a specific scroll offset, such as scrollTop on a nested scroller or the document’s scroll position.
  • Same content item: keep a particular article section, card, or other identifiable element at a chosen position in the viewport.
  • Stable reading view: let the browser compensate for layout changes outside the viewport while the viewer stays in place.

These goals are not interchangeable. If content is inserted above the viewport, a fixed pixel offset may point to a different item; preserving the item may require changing the offset.

Pick the technique that matches the change

Technique Best suited to Main control Limitation
History restoration Returning through browser session history history.scrollRestoration Controls history navigation, not whether a dynamic page is settled for capture. MDN reference.
CSS scroll anchoring Keeping the visible area steady as content outside it changes Browser-selected anchor; overflow-anchor opt-out Support and page behavior vary; opt-outs and suppression triggers can prevent it. MDN overview and CSS reference.
Application-managed restoration Keeping a specific item or custom coordinate through app-controlled updates Save a stable item identifier and its relative position, or save an offset The right anchor and restoration timing depend on the application; there is no universal browser algorithm for this.
ResizeObserver-assisted response Detecting size changes in relevant elements Observe an element’s content or border-box size and schedule app logic A resize notification does not prove every dynamic task is complete, and callback writes can cause repeated resize cycles. MDN reference.

Preserve scroll position step by step

  1. Identify the actual scrolling box. A page may scroll the document or a nested element. Read and restore the position on that scroller, not an assumed one.
  2. Choose the invariant. Save an offset for coordinate fidelity. For content fidelity, save a stable identifier for the item and its position relative to the scroll container. This is application-level design guidance; browser primitives do not prescribe a universal choice.
  3. Keep native history restoration unless taking ownership. For browser back/forward behavior, the default is auto. Set manual only when your application will implement restoration itself. MDN documents the property at History: scrollRestoration property.
  4. Allow scroll anchoring to handle ordinary shifts where appropriate. Do not disable it with overflow-anchor: none without a specific reason. If you do opt a region out, account for the effect on descendants. Test the target browser/device matrix: MDN’s compatibility guidance describes support as newly available across latest browser versions and devices since September 2026, while warning that older devices may not support it. See MDN’s overview.
  5. Use ResizeObserver only as a signal. Observe relevant content or container sizes, then schedule the restoration decision. Avoid writes in the observer callback that repeatedly change the observed size; when an intentional change must be deferred, use requestAnimationFrame as described in the MDN Resize Observer documentation.
  6. Capture after the relevant page-specific work completes. Wait for the content and layout changes that matter to your target page, using a reliable completion signal exposed by that page or capture workflow. These browser APIs do not provide a general “page is settled” test.

Example: restore a content item in a nested scroller

When the content item matters more than a raw pixel offset, record the item’s distance from the scroller’s top edge. After the page’s relevant updates, measure again and adjust the scroller by the difference. This example assumes the application gives each item a stable identifier and calls restoreItemPosition only after its own relevant update has completed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
function saveItemPosition(scroller, item) {
  return {
    id: item.dataset.itemId,
    top: item.getBoundingClientRect().top - scroller.getBoundingClientRect().top,
  };
}

function restoreItemPosition(scroller, saved) {
  const item = scroller.querySelector(
    `[data-item-id="${CSS.escape(saved.id)}"]`
  );
  if (!item) return false;

  const currentTop = item.getBoundingClientRect().top - scroller.getBoundingClientRect().top;
  scroller.scrollTop += currentTop - saved.top;
  return true;
}

const scroller = document.querySelector(".results");
const item = scroller.querySelector('[data-item-id="article-42"]');
const saved = saveItemPosition(scroller, item);

// Call after the application knows relevant dynamic updates have completed.
restoreItemPosition(scroller, saved);

The identifier must remain stable across the update, and the item must still exist. If it has been removed, decide explicitly whether to use a neighboring item, a saved coordinate, or no restoration. For exact coordinate restoration instead, save the relevant scroller’s scrollTop and restore that value when the layout is ready. For document scrolling, use the document’s scrolling element rather than assuming a nested container.

When history navigation is the only requirement

Leave the browser’s default behavior in place unless the application has a complete custom restoration path. If you intentionally take over, configure it explicitly:

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
// Leave native history restoration enabled (the default):
history.scrollRestoration = "auto";

// Delegate restoration to application code:
history.scrollRestoration = "manual";

Choosing manual alone does not save or restore anything. The application must store the needed position and restore it at an appropriate point in its navigation lifecycle. The History API setting is specifically about session-history navigation, not a general capture wait mechanism.

Troubleshoot unexpected movement or capture position

  • The wrong region is restored: inspect which element actually scrolls. A nested scroller’s position is independent of the document’s.
  • The same offset shows different content: content above the offset changed height. Save and restore an identifiable item’s relative position instead, if content identity is the goal.
  • The visible content jumps despite anchoring: check whether the relevant container or an ancestor is opted out with overflow-anchor: none, and verify support in the capture browser. Anchoring behavior can also be suppressed by browser rules.
  • The page moves after restoration: restoration likely happened before a relevant image, component, or other dynamic update changed layout. Wait for a page-specific completion signal, then re-evaluate; a resize notification by itself is not proof that all activity is done.
  • Resize callbacks keep firing: check whether callback writes alter the dimensions being observed. Avoid that feedback loop or defer intentional changes with requestAnimationFrame.
  • Restoration code has no effect on back navigation: confirm whether history.scrollRestoration is manual and whether the app actually implements the corresponding save-and-restore path.

Performance, reliability, and cost considerations

Prefer native history restoration and browser scroll anchoring when they match the requirement; they avoid building application-specific coordination for those cases. Add observation and custom correction only for content or timing the native behavior does not handle. Observe only relevant elements and ensure correction code cannot repeatedly resize them. No measured performance comparison or universal reliability figure is established for these techniques; behavior depends on the page, browser, and capture workflow.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server. One GET request captures a URL as PNG, JPEG, WebP, or PDF. For a URL screenshot, see the API documentation:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo accepts cookie/consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses include X-Page-Verdict and X-Billed headers. Its MCP server gives AI agents tools to take screenshots, get page information, and capture PDFs. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for 1,000 free screenshots a month—no card required.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Frequently Asked Questions

Does ResizeObserver tell me when a page is ready for a screenshot?

No. It reports observed element size changes; it does not establish that all dynamic page activity has finished.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can I preserve a specific item instead of a pixel offset?

Yes. Store a stable identifier for the item and its position relative to the relevant scroll container, then restore that relationship after the relevant updates.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Should I set history.scrollRestoration to manual?

Only if your application is taking responsibility for saving and restoring positions during session-history navigation.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.