You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the Turbo documentation here: https://turbo.hotwired.dev/handbook/building#working-with-script-elements adding JS files into a page's <head> that are not present on the current page should cause Turbo Drive to merge the <head> and load the JS code on demand. Quoting the documentation:
When you navigate to a new page, Turbo Drive looks for any elements in the new page’s which aren’t present on the current page. Then it appends them to the current where they’re loaded and evaluated by the browser. You can use this to load additional JavaScript files on-demand.
And we add these additional JS files in a view like:
<%= content_for :head do %>
<%= javascript_include_tag 'page_specific_code', 'data-turbo-track': 'reload' %>
<% end %>
However Turbo always does a full page reload when it encounters these types of views.
To confirm this is happening, we have the following in our application.js:
$(document).on("turbo:reload", function () {
alert("TURBO FULL RELOAD!");
});
This seems to conflict with what the documentation claims around merging the heads and adding the files as on demand and only do a full reload if the fingerprints have changed. We have this approach in a lot of our views which makes using Turbo feel almost pointless as it means the page is being fully reloaded between views (and we don't want to have to rebuild our application setup to make Turbo work with it).
We tried removing the 'data-turbo-track': 'reload' from the page_specific_code and it stopped doing the full reload... however the fingerprints of the files haven't changed so the turbo-track-reload shouldn't be causing it to happen. Perhaps it's not clear in the documentation but it almost sounds like you should only use the reload on the global bundled files that are used across the app and anything that's page specific then you shouldn't otherwise it just does a full refresh. Is that correct? Or is something else happening here that's considered a bug?
The text was updated successfully, but these errors were encountered:
According to the Turbo documentation here: https://turbo.hotwired.dev/handbook/building#working-with-script-elements adding JS files into a page's
<head>
that are not present on the current page should cause Turbo Drive to merge the<head>
and load the JS code on demand. Quoting the documentation:Our head looks like:
And we add these additional JS files in a view like:
However Turbo always does a full page reload when it encounters these types of views.
To confirm this is happening, we have the following in our
application.js
:This seems to conflict with what the documentation claims around merging the heads and adding the files as on demand and only do a full reload if the fingerprints have changed. We have this approach in a lot of our views which makes using Turbo feel almost pointless as it means the page is being fully reloaded between views (and we don't want to have to rebuild our application setup to make Turbo work with it).
We tried removing the
'data-turbo-track': 'reload'
from thepage_specific_code
and it stopped doing the full reload... however the fingerprints of the files haven't changed so theturbo-track-reload
shouldn't be causing it to happen. Perhaps it's not clear in the documentation but it almost sounds like you should only use the reload on the global bundled files that are used across the app and anything that's page specific then you shouldn't otherwise it just does a full refresh. Is that correct? Or is something else happening here that's considered a bug?The text was updated successfully, but these errors were encountered: