For turbolinks 5.0 you must use the turbolinks:load event, which is called the first time on page load and every time on a turbolink visit. More info: https://github.com/turbolinks/turbolinks#running-javascript-when-a-page-loads
CoffeeScript code:
$(document).on 'turbolinks:load', ->
my_func()
JavaScript code:
document.addEventListener("turbolinks:load", function() {
my_func();
})