Element.scrollBy() scrolls an element by the given amount relative to its current position (MDN). Pass (x, y) deltas or an options object with top, left, and behavior. For absolute coordinates, use scroll() / scrollTo().
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call el.scrollBy. Start with this line.
JavaScript
el.scrollBy(x, y) or el.scrollBy(options)
Call
What it does
el.scrollBy(x, y) or el.scrollBy(options)
Primary signature.
el.scrollBy(...)
Call with the arguments your case needs.
Built into the browser. Call scrollBy(...) on an Element — no import required.
Library declarations
JavaScript
el.scrollBy(x, y) or el.scrollBy(options)
Parameters
Parameter
Description
options.behavior
Optional. smooth, instant, or auto
Negative values
Optional. Scroll up / left
Return Value
Return Value
Description
*
Promise<{ interrupted }> (support varies)
JavaScript Examples
Example 1 — Scroll by a Delta
MDN: scroll an element by a given amount from the current position.
Await finish. Useful for smooth “next page” buttons.
interrupted. True if another programmatic scroll started first.
Feature-detect. Test box.scrollBy(0, 0) instanceof Promise.
Fallback. If no Promise, the scroll still runs — just no await.
Compatibility
Browser Support
Element.scrollBy() is Baseline Widely available (MDN, since January 2020). It is not Deprecated, Experimental, or Non-standard. Promise return / interrupted may vary — feature-detect if you depend on it.
✓ Baseline Widely available
Element.scrollBy()
Scroll an element by a relative delta. Pair with scroll/scrollTo for absolute jumps.
BaselineWidely available
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
Android WebViewSupported · Modern WebView
Full support
scrollBy()Baseline
Bottom line: Safe for modern apps. Prefer options + behavior for smooth UX; detect Promise support before awaiting.
Frequently Asked Questions
It scrolls an element by the given amount relative to its current position (MDN). Pass x/y deltas or an options object with top, left, and behavior.
No. MDN marks Element.scrollBy() as Baseline Widely available (since January 2020). It is not Deprecated, Experimental, or Non-standard. Some parts (such as the Promise return) may vary by browser.
MDN documents a Promise that fulfills with { interrupted }. interrupted is true if another programmatic scroll started on the same element before the first finished. Feature-detect if you rely on the Promise.
scrollBy() adds a delta to the current scroll position. scroll() / scrollTo() jump to absolute coordinates inside the element.
Optional string: smooth (animate), instant (jump), or auto (use the element’s CSS scroll-behavior). Default is auto (MDN).
Yes. Use negative deltas, e.g. scrollBy(0, -40) or scrollBy({ top: -40 }).