I wanted to add a scroll to top button to my website. I didn’t want it to rely on being random buttons in the middle of the html. A button like this makes way more sense to be affixed to the UI. It also shouldn’t be visible when you can’t actually scroll up. Mark Goodyear wrote a great (and simple) jQuery plugin to do this: ScrollUp it is MIT licensed and you can check out the source on github.
$(function () { $.scrollUp(); });
Is literally all the source it takes after you include jquery and jquery.scrollup.js files to your page.
It is also highly configurable. Definitely worth a look.