If you need a plain JavaScript function to add a smooth scrolling back to the top of the page, you can use this script.

Seriously, plain/vanilla Javascript. No JQUERY...!!

 

All you need to do is add the below script tag at the bottom of your page. 

And thats it.!! You are done.

View Demo 

 

<script type="text/javascript" src="http://www.LiveWebTraffic.com/code-snippets/scrollToTop/scrollToTop.min.js"></script>


If you do not want to include the script , you can simply copy the code mentioned below and add it in your js file.

 

function animateToTop(o){o.preventDefault();var t=window.setInterval(function(){var o=window.pageYOffset;o>0?window.scrollTo(0,o-20):window.clearInterval(t)},16)}window.onload=function(){var o=document.createElement("div");o.setAttribute("id","scrollToTopElement"),o.setAttribute("style","display:none;color: #fff;position: fixed;bottom: 35px;right: 25px;width: 50px;height: 50px;text-align: center;cursor: pointer;background-color: rgb(40, 167, 233);z-index: 1005;box-shadow: 0 1px 2px #bbb;opacity:0;transition: opacity 2s;"),o.className+="scrollToTop hidden-xs";try{o.innerHTML='<p style="font-size: 30px;font-weight: bold;">&#8593;</p>',document.body.appendChild(o)}catch(t){o.text=code,document.body.appendChild(o)}o.onclick=function(o){animateToTop(o)}},window.onscroll=function(){var o=document.getElementById("scrollToTopElement");o&&(0!==window.pageYOffset?(o.style.display="block",o.style.opacity=1):(o.style.display="none",o.style.opacity=0))};

 

Hope you like it. :)