7
Make Rails app’s page loads faster with Wiselinks Vu Ngoc Anh

Make Rails app’s page loads faster with Wiselinks

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Make Rails app’s page loads faster with Wiselinks

Make Rails app’s page loads faster with Wiselinks

Vu Ngoc Anh

Page 2: Make Rails app’s page loads faster with Wiselinks

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

Page 3: Make Rails app’s page loads faster with Wiselinks

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

Page 4: Make Rails app’s page loads faster with Wiselinks

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

Page 5: Make Rails app’s page loads faster with Wiselinks

Demo

Page 6: Make Rails app’s page loads faster with Wiselinks

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’

Page 7: Make Rails app’s page loads faster with Wiselinks

Thank you

• https://github.com/igor-alexandrov/wiselinks