|
|
|
|
|
by AnneOminous
3690 days ago
|
|
Turbolinks is great for some use-cases (like Basecamp for example). But it is not for everybody. It absolutely sucks for other use-cases. Among other things, since its inception it has messed with the CSS heirarchy, resulting in the fact that by default it loads all the CSS and JavaScript for all pages, in an order you probably don't want. (Note: there is a reason the "C" in CSS stands for "Cascading". It wasn't designed to all be loaded at once.) If you DO want "one page apps", then fine. If you don't, and you have a significant site with more than a couple of dissimilar pages, it will probably be more performant if you disable Turbolinks and load only the JavaScript and CSS necessary for a given page, i.e., the conventional approach. |
|
"sucks for other use cases"? Which use cases have you use TurboLinks where it wasn't a good fit?
Basecamp isn't a trivial one page app; it has over 200+ screens.
For page changes, CSS is generally scoped by controller action classes. Quick look up by the browser, penalty negligible.
All of the JS is loaded, but again, you can invoke the needed js for the page by looking at the body/action selector. Again, a few if checks on the "page:change" callback.
Weighed against the traditional: a full request to the server which includes a download of relevant CSS for the page, a download of relevant javascript for the page, parsing of that css, parsing of js, and then execution of that js.