I have a rails application using turbolinks
one page i should load script, and i don't want load it on all the application
specific add it on page like that
<% content_for :head do %>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<% end %>
my problem is while i enter to page via turbolinks the script doesn't load
how can i load single js on specific page
thanks!
Turbolinks will NOT update head. That's where the advantage is. The loading speed will be much faster without head reloading. That's why your content_for :head won't work.
For your case, the simplest solution is to put the script tag directly on page template.
Maybe adding data-no-turbolink to your script tag helps you.
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false" data-no-turbolink></script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With