Improve anchor_links.html

I will rebase this as soon as https://github.com/jekyll/jekyll/pull/2367 is merged.

* fix `TypeError` since `containingElement` is undefined when we are in home
* remove default type and encoding
* format the code
* move JS before `</body>`