4 ms·
Rails 4 uses turbolinks. It is a mechanism that instead of loading a new page loads up the HTML via AJAX and replaces the entire content of the page without re
by xutopia 14y ago
Rails 4 uses turbolinks. It is a mechanism that instead of loading a new page loads up the HTML via AJAX and replaces the entire content of the page without reloading all the resources(css, js, etc...)
So instead of having to deal with plenty of small ajax calls you just build an app as it would work in plain HTML and just use turbolinks to leverage AJAX.
- merry-christmas 14y agoFunny that ASP.NET had the same thing, called Smart Navigation, back in 2003.
- anko 14y agosmart navigation is very different. Besides not being supported across browsers, it was more like automatic anchoring.
- merry-christmas 14y agoNope, it's not automatic anchoring. It uses JS (iframe AJAX) to retrieve a new page from the server and display it without flicker.
- byroot 14y ago2003 or 2013, ASP or Rails both are terrible ideas IHMO. At least as a default. Sure it can be very efficient, but it's a terrible default. When DHH state: > except, maybe, compatibility issues with some existing JavaScript packages Some ? Don't you mean most ? Even Twitter Bootstrap will leak memory if used in a turbolink app. When coffeescript is pushed as default, I'm ok, at worst you don't use it and you have a useless gem. But turbolink is harmful if you don't know what you are doing.
- emidln 14y agoMuch further after that, there was a jQuery plugin called taconite that let you do this from arbitrary languages. The idea was that you can handle all of your templating server side and build the template into a simple xml document that had tags corresponding to jquery dom manipulation functions. You return the template with the right mimetype, and the plugin handles translating your xml template into a dom update. This has been handy a few times to keep all of the display logic centralized in a single templating mechanism.
- joesb 14y agoTurboLink does less, so there are less things to screw up. TurboLink always replace the whole body, not just part of the page. There's no input focus to maintain. Server side render a page the same regardless of whether it's fetched normally or through TurboLink. Links fallback correctly on JS-disabled client.
- pmarsh 14y agoBut if two pages have the same resource URLs for their css, js, etc they should be cached by the browser so moving from page to page shouldn't be reloading them. This does not seem like a super great idea, like merry-christmas mentioned too much like ASP.NET. I'll do some reading on turbolinks and see if there's something super I'm missing.
- steveklabnik 14y agoI did some speed tests here: https://github.com/steveklabnik/turbolinks_test https://github.com/steveklabnik/turbolinks_test Apparently, even though the browser doesn't re-download the assets, it does re-parse and re-execute all of it. Which makes sense. This is where Turbolinks adds the speedup.