Just wanted to say that I ran into this issue as well, not with different frameworks, but with different layouts. I was navigating from one layout to another layout, and each layout has its own CSS file. The problem is, there are some naming collisions in my CSS classes and one layout’s CSS started overwriting the CSS classes from the previous layout.
I believe this is the expected behaviors since Turbo Drive merges the contents of the <head> tag on navigation. From the documentation:
During rendering, Turbo Drive replaces the current <body> element outright and merges the contents of the <head> element. The JavaScript window and document objects, and the <html> element, persist from one rendering to the next.
The way I’m coping with this is that I’m going to unify my CSS and make sure that there are no conflicting names.
For you, dealing with two different frameworks sounds extra challenging. I don’t have any good advice there, sorry. Maybe the best thing to do would be turn off Turbo Drive[data-turbo="false"] on links where you’re about to navigate away from one framework and into another. This will cause a full-page refresh, which will give you a blank slate, so to speak.
FYI, I include data-turbo-track="reload" on all my css or javascript assets that I anticipate may change over time anyway. It also works in the above scenario, where an asset is no longer loaded (e.g. in a new layout), it will force a reload. A more dynamic version of data-turbo="false"] in that it clears cache as needed, not on every request.
Correct. However, for the original posted scenario where the a CSS link is added to one HTML Head, but removed at some point in a request. If the link includes data-turbo-track="reload", it will force a turbo reload and prevent the issue of having both assets in the head at the same time.