forked from hotwired/turbo-site
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document
[data-turbo-track="dynamic"]
Follow-up to [hotwired/turbo#1140][] Removing Assets When They Change --- As we saw above, Turbo Drive merges the contents of the `<head>` elements. When a page depends on external assets like CSS stylesheets that other pages do not, it can be useful to remove them when navigating away from the page. Rendering a `<link>` or `<style>` element with `[data-turbo-track="dynamic"]` instructs Turbo Drive to dynamically remove the element when it is absent from a navigation's response, and can serve a complementary role to the `[data-turbo-track="reload"]` attribute to avoid triggering a full page reload when deploying changes that only affect styles. ```html <head> <!-- … --> <link rel="stylesheet" href="/page-specific-styles-258e88d.css" data-turbo-track="dynamic"> <style data-turbo-track="dynamic"> .page-specific-styles { /* … */ } </style> </head> ``` Note that rendering `<script>` elements with `[data-turbo-track="dynamic"]` might unintended side-effects. When `<script>` disconnected from the document, the JavaScript context doesn't change, nor is the element's already evaluated JavaScript code unloaded or changed in any way. [hotwired/turbo#1140]: hotwired/turbo#1140
- Loading branch information
1 parent
5cf3013
commit cd9075c
Showing
2 changed files
with
24 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters