make rails app’s page loads faster with wiselinks
DESCRIPTION
TRANSCRIPT
![Page 1: Make Rails app’s page loads faster with Wiselinks](https://reader036.vdocuments.us/reader036/viewer/2022081813/54bd18164a7959f95e8b45b9/html5/thumbnails/1.jpg)
Make Rails app’s page loads faster with Wiselinks
Vu Ngoc Anh
![Page 2: Make Rails app’s page loads faster with Wiselinks](https://reader036.vdocuments.us/reader036/viewer/2022081813/54bd18164a7959f95e8b45b9/html5/thumbnails/2.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022081813/54bd18164a7959f95e8b45b9/html5/thumbnails/3.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022081813/54bd18164a7959f95e8b45b9/html5/thumbnails/4.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022081813/54bd18164a7959f95e8b45b9/html5/thumbnails/5.jpg)
Demo
![Page 6: Make Rails app’s page loads faster with Wiselinks](https://reader036.vdocuments.us/reader036/viewer/2022081813/54bd18164a7959f95e8b45b9/html5/thumbnails/6.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022081813/54bd18164a7959f95e8b45b9/html5/thumbnails/7.jpg)
Thank you
• https://github.com/igor-alexandrov/wiselinks