jQuery Smooth Scroll to Anchor

Have you ever wanted to smoothly scroll to an anchor on a page with jQuery? The script example I have provided allows several functionalities. If you enter a page with an anchor hash directly, it will smooth scroll to that point on the page. It will also update the hash, and calculateĀ the height of a sticky header or menu.

This works best as an inline script, but does also work when placed insideĀ a JavaScript file.