If you need a plain JavaScript function to add a smooth scrolling back to the top of the page, you can use this script:
window.scrollTo({top: 0, behavior: "smooth"});
How? 👉 Just add this script to a <button>
element in the onclick:
attribute, like this (and place it at the bottom of your page):
<button onclick='window.scrollTo({top: 0, behavior: "smooth"});'>Back to Top ↑</button>
CodePen demo here: (https://codepen.io/ricardozea/pen/NWpgyjL) by Ricardo Zea on CodePen.
Thank you for your update.
this script simple and working perfect