Scroll to Top

Smooth scroll to the top of the page with optional animation control.

Code

Utilities
const scrollToTop = (useSmooth = smooth) => {
  window.scrollTo({ top: 0, behavior: useSmooth ? 'smooth' : 'auto' });
};
return "Scroll function created";

Parameters

Use smooth scrolling.

Browser·fetch() may be limited by CORS

More JavaScript Snippets