The Ruby on Rails version 4.0.0 has been just released. The team took one and half years for development, Rails 4 comes with some interesting new features such as Turbolinks, improved caching and thread-safe.
[ This is similar to pjax, but here we dont need to worry about which element on the page to replace, and combining the server-side response to add, The entire body will be replaced ]
Few major points on Turbolinks
1. Less Execution time : -
- In any case, the benefit can be up to two times faster in apps with lots of JS and CSS. Of course, your app's speed may vary, It'll be dependent on your browser version and all other factors affecting performance of your application.
2. No jQuery or any other framework : -
- Turbolinks is built as light-weight.
- It does not require jQuery or any other framework to work. But it works fine with jQuery or Prototype or whatever else like these frameworks.
3. Events :-
- Turbolinks changes the pages without a full
page reload, so you can't rely on
jQuery.ready()to trigger your code.
- Instead Turbolinks triggers events on
documentto provide hooks into the lifecycle of the current page
- Turbolinks will be enabled whenever
the server has rendered a
POST :create=> resource successfully created => redirect to
- Turbolinks ENABLED
POST :create=> resource creation failed => render
- Turbolinks DISABLED
5. Opting out of Turbolinks
- By default, Turbolinks is enabled for all internal HTML links.
- You can opt out by marking links or their parent
- After giving
data-no-turbolink attr with in adiv, then all links inside of that div will be treated as regular links.
Eg :- <a href="#">Home (via Turbolinks)</a> <div data-no-turbolink> <a href="#">Home (without Turbolinks)</a> </div>
6. Visit links manually using turbolinks
You can use
Turbolinks.visit(path)to go to a URL through Turbolinks.