Closed nickjj closed 2 years ago
I feel like a lot of people will want this. I submitted a PR that "kinda" fixes this. Turbo Frames/Streams are opt-in, in the sense that it doesn't mess with existing ERB/JS stuff by installing Turbo. Drive is the only part that is opt-out, meaning it's enabled and disruptive by default (e.g., it breaks lots of existing javascript). My PR would allow the user to reverse this behavior when the module is imported, and users would use data-turbo="true"
to selectively enable it, rather than using data-turbo="false"
to selectively disable it. It's nice particularly in projects where you have a lot of layouts, dynamically generated layouts, or customer-controlled layouts and you want to permit new Turbo functionality without requiring changes to existing stuff.
+1
I know it's asking a lot but I'd really like to see something happen before 1.0.
Importing Turbo beta 7 into a project increases my JS payload by 188kb. That is not minified or gzipped, but it's still a lot, especially when StimulusJS is another 181kb. Before you know it, just pulling in these 2 libraries puts you close to 400kb of JS before writing a single line of app level JS.
+1
Appreciate the instinct. But compressed, Turbo is 19kb, and Stimulus is 9kb. It's just not going to be worth the effort to optimize that further weighed against the complications to do so.
Just to revisit, would a PR be accepted considered to separate the 3? You'd just need different file paths for each.
import "@hotwired/turbo/{drive, frames,streams}"
Obviously there's more to it around disentangling the 3, but am curious if a PR would at least be considered
seems like there was a positive reaction here: https://github.com/hotwired/turbo/issues/369
Would be happy to consider a PR, but the tolerance for added complexity in order to reach this separation is very low. If you can find a super simple way to do it, though, I see no harm in that 👍
Hi,
In cases where you want to use Drive but not Frames / Streams it might be beneficial to be able to import Drive by itself.
I'm not sure how to calculate the size of each piece as it stands now but is this worth exploring?
Turbo as a whole is much much larger than Turbolinks 5 and using Turbolinks 5 to get Drive-like behavior isn't quite the same because Drive is so much better in regards to handling form submissions and not needing anything server side.