Inlined javascript in main templates

Since the "invisible menu" javascript code is relatively small, fetching
it separately from the main template is a performance hit (as reported
by, for example, https://developers.google.com/speed/pagespeed/ ).

Another small performance tweak is to mark the scripts as async since
they execute only on user interaction (this way, the browser can ignore
the JS while rendering the page).