This lets you load application JavaScript asynchronously from <head>. Compatible with Turbolink v2, v5.0, v5.1, jquery-turbolinks, and no Turbolinks. Compatible with all browsers and IE9+ (only IE10+ will actually benefit from this though).
How to use this:
-
Add the HTML snippet just before the closing
</body>tag. -
Add the on_page_load.js script to the beginning of your
application.js, and usewindow.App.onPageLoad(...)instead ofdocument.addEventListener('DOMContentLoaded', ...)andjQuery(($) -> ...)everywhere. -
Include your JavaScript like so:
<head>