Upload
framgia-vietnam
View
955
Download
0
Embed Size (px)
DESCRIPTION
Citation preview
Make Rails app’s page loads faster with Wiselinks
Vu Ngoc Anh
What’s Wiselinks
• Is a gem likes Turbolinks to make page loads faster by using AJAX and history APIs as pushState to replace the content of page instead of re-rendering all of the page
• pushState is a method of History API (HTML5) allows Javascript to store data in session history with title & url
• Turbolinks is shipped as default in Rails 4
The difference with Turbolinks
• Wiselinks work as a whitelist when Turbolinks work as blacklist
• Processes 30x http redirects• Works in browers that don’t have History API• Can handle form processing
Installation
• Add “ gem ‘wiselinks’ ” to Gemfile then bundle• Add “//= require wiselinks” and create
wiselinks object “window.wiselinks = new Wiselinks()” in application.js
• Add attribute “ data-push=‘true’ ” to link want to use wiselink
Demo
Notes
• Use ‘wiselinks_title’ helper to set title of page• Problem when using ‘document.ready’• Event: ‘page:loading’, ‘page:redirected’,
‘page:always’, ‘page:done’, ‘page:fail’
Thank you
• https://github.com/igor-alexandrov/wiselinks