SlideShare a Scribd company logo
Turbolinks + Vue.js
Pascal Laliberté
Starting small Depth
WHAT I VALUE
Turbolinks Vue.js
WHICH IS WHY I’M ATTRACTED
TO THESE TWO TECHNOLOGIES
Turbolinks
A PAGE HAS A BODY
AND A HEAD
<head>
A PAGE HAS A BODY
<head>
Replaces
the body
with the new
content
<head>
WITH TURBOLINKS, CLICKING A LINK…
<head>
Replaces
the body
with the new
content
<head>
WITH TURBOLINKS, CLICKING A LINK…
Merges
the head
<head>
Replaces
the body
with the new
content
<head>
WITH TURBOLINKS, CLICKING A LINK…
Merges
the head
It keeps a Cache of snapshots

For Back operations, etc
<head>
Replaces
the body
with the new
content
<head>
WITH TURBOLINKS, CLICKING A LINK…
Merges
the head
It keeps a Cache of snapshots

For Back operations, etc
WHICH MAKES PAGE TRANSITIONS

(AND PAGE RESTORES)
SUPER QUICK
Vue.js
jQuery
In the category of
Front-end UX
Dev Tools
jQuery Vanilla JS
In the category of
Front-end UX
Dev Tools
Angular
A full-fledge client-side
MVC
jQuery Vanilla JS
In the category of
Front-end UX
Dev Tools
React
Angular
A full-fledge client-side
MVC
jQuery Vanilla JS
In the category of
Front-end UX
Dev Tools
React
Angular
A full-fledge client-side
MVC
jQuery Vanilla JS
In the category of
Front-end UX
Dev Tools
View renderers
React
Angular
A full-fledge client-side
MVC
Vue
jQuery Vanilla JS
In the category of
Front-end UX
Dev Tools
View renderers
AS AN EXAMPLE, LET’S TAKE A FORM FIELD
<div class=“purchase-form”>
<input v-model=“quantity”>
AS AN EXAMPLE, LET’S TAKE A FORM FIELD
AS PART OF A PURCHASE FORM…
new Vue({
el: “.purchase-form”,
data: {
}
quantity: null
})
<div class=“purchase-form”>
<input v-model=“quantity”>
WHEN WE SETUP THE VUE INSTANCE, WE SET THE MODEL
new Vue({
el: “.purchase-form”,
data: {
}
quantity: 2
}
2
<div class=“purchase-form”>
<input v-model=“quantity”>
})
AS THE FORM FIELD’S VALUE CHANGES,
SO DOES THE VALUE IN THE MODEL
new Vue({
el: “.purchase-form”,
data: {
}
quantity: 23
}
23
<div class=“purchase-form”>
<input v-model=“quantity”>
})
AS THE FORM FIELD’S VALUE CHANGES,
SO DOES THE VALUE IN THE MODEL
AND VICE VERSA
,
price: 25
}
new Vue({
el: “.purchase-form”,
data: {
quantity: 23
})
23
WE CAN ADD OTHER PROPERTIES TO THE MODEL
,
price: 25
}
new Vue({
el: “.purchase-form”,
data: {
quantity: 23
})
23
,
computed: {
total () {
return this.quantity
* this.price
}
}
AND COMPUTED PROPERTIES TOO, WHICH UPDATE ON THE FLY
,
price: 25
}
new Vue({
el: “.purchase-form”,
data: {
quantity: 23
})
23
methods
events
components
,
computed: {
total () {
return this.quantity
* this.price
}
}
YOU CAN ALSO DEFINE
<map-popover
:lat=“lat”
:long=“long”
:zoom=“zoom”
></map-popover>
DEFINING SUB-COMPONENTS MAKES VUE SCALABLE
React
Angular
Vue
jQuery Vanilla JS
SPA
Front-end UX
vue-router
vue-resource
SPA
YOU CAN GO ALL OUT
AND BUILD A SPA…
Approachable
Small
Fast
Delightful
Scalable
BUT VUE’S BEST QUALITIES ARE THAT IT IS
Now available: Vue.js 2.0
IF YOU WANT
mostly server-generated content
in places: more front-end reactivity
Turbolinks + Vuejs
mostly jQuery / Vanilla js, Unobtrusive JS
<head>
Replaces
the body
with the new
content
<head>
WITH TURBOLINKS, CLICKING A LINK…
Merges
the head
It keeps a Cache of snapshots

For Back operations, etc
THE PROBLEM MERGING THEM TOGETHER
IS THE BODY REPLACEMENT
CAUSES VUE INSTANCES TO LOSE REACTIVITY
ON RESTORES
Turbolinks + Vuejs
new Vue({
el: “.purchase-form”,
data: {
}
quantity: 23
}
23
REACTIVITY = DOM EVENTS, OBSERVERS
DESTROYED WHEN CLONING THE BODY
FOR THE RESTORE CACHE
FOR THE SOLUTION
LET’S LOOK AT THE TIMELINE OF EVENTS
turbolinks:load
FOR THE SOLUTION
LET’S LOOK AT THE TIMELINE OF EVENTS
turbolinks:load turbolinks:before-cache
FOR THE SOLUTION
LET’S LOOK AT THE TIMELINE OF EVENTS
turbolinks:load turbolinks:before-cache
init destroy(Vue.js events)
FOR THE SOLUTION
LET’S LOOK AT THE TIMELINE OF EVENTS
turbolinks:load turbolinks:before-cache
init destroy
re-inject in turbolinks
snapshot the original DOM
element with end data
(serialized) injected
(Vue.js events)
turbolinks:load turbolinks:before-cache
init destroy
save initial DOM
element before it’s
walked
re-inject in turbolinks
snapshot the original DOM
element with end data
(serialized) injected
(Vue.js events)
turbolinks:load turbolinks:before-cache
init destroy
save initial DOM
element before it’s
walked
re-inject in turbolinks
snapshot the original DOM
element with end data
(serialized) injected
detect serialized
start data attached to
initial DOM element
(Vue.js events)
turbolinks:load turbolinks:before-cache
init destroy
save initial DOM
element before it’s
walked
re-inject in turbolinks
snapshot the original DOM
element with end data
(serialized) injected
detect serialized
start data attached to
initial DOM element
Vue.js Mixin
(Vue.js events)
turbolinks:load turbolinks:before-cache
init destroy
save initial DOM
element before it’s
walked
re-inject in turbolinks
snapshot the original DOM
element with end data
(serialized) injected
detect serialized
start data attached to
initial DOM element
Vue.js Mixin …for each Vue component on the page
(Vue.js events)
@pascallaliberte
pascallaliberte.me

More Related Content

PPTX
MeteorJS Session
PDF
PWA 與 Service Worker
PPTX
Getting started with k8
PDF
clj and deps.edn
PDF
Ansible with oci
PDF
Spring Booted, But... @JCConf 16', Taiwan
PDF
Magnolia CMS Tasks & Workflows
PDF
Spring Boot - Microservice Metrics Monitoring
MeteorJS Session
PWA 與 Service Worker
Getting started with k8
clj and deps.edn
Ansible with oci
Spring Booted, But... @JCConf 16', Taiwan
Magnolia CMS Tasks & Workflows
Spring Boot - Microservice Metrics Monitoring

What's hot (20)

PDF
BOSH / CF Deployment in modern ways #cf_tokyo
PDF
Service Worker - Reliability bits
PPTX
Access google command list from the command line
PDF
PWA 應用 - 實現網站離線瀏覽
PDF
Spring Boot
PPTX
Service workers and the role they play in modern day web apps
PPTX
Azure Blockchain Workbench cloud
PPT
Building and Deployment of Drupal sites with Features and Context
PPTX
Best Practices for creating WP REST API by Galkin Nikita
PDF
Big query - Command line tools and Tips - (MOSG)
PDF
From Spring Boot 2.2 to Spring Boot 2.3 #jsug
PPTX
learn what React JS is & why we should use React JS .
PDF
Using React with Grails 3
PPTX
Transfer to kubernetes data platform from EMR
PDF
Open Service Broker APIとKubernetes Service Catalog #k8sjp
PDF
GreenButton-201502
PPTX
Offline First with Service Worker
PDF
Ember Reusable Components and Widgets
PDF
Scala Vienna Website: reloaded
PDF
Liberating web apps from the server
BOSH / CF Deployment in modern ways #cf_tokyo
Service Worker - Reliability bits
Access google command list from the command line
PWA 應用 - 實現網站離線瀏覽
Spring Boot
Service workers and the role they play in modern day web apps
Azure Blockchain Workbench cloud
Building and Deployment of Drupal sites with Features and Context
Best Practices for creating WP REST API by Galkin Nikita
Big query - Command line tools and Tips - (MOSG)
From Spring Boot 2.2 to Spring Boot 2.3 #jsug
learn what React JS is & why we should use React JS .
Using React with Grails 3
Transfer to kubernetes data platform from EMR
Open Service Broker APIとKubernetes Service Catalog #k8sjp
GreenButton-201502
Offline First with Service Worker
Ember Reusable Components and Widgets
Scala Vienna Website: reloaded
Liberating web apps from the server
Ad

Viewers also liked (20)

PDF
Happiness and design
PDF
Vue.js for beginners
PDF
Vue js and Vue Material
PDF
Enjoy the vue.js
PDF
Why Vue.js?
PPTX
Vue 2.0 + Vuex Router & Vuex at Vue.js
PPTX
Vue.js
PPTX
PPT
Pneumobilia vs portal vein gas
PDF
Vue 淺談前端建置工具
PDF
Javascript MVVM with Vue.JS
PDF
Vue.js
PDF
Vue.js is boring - and that's a good thing
PDF
從改寫後台 jQuery 開始的 Vue.js 宣告式渲染
ODP
An Introduction to Vuejs
PPTX
PPTX
Vue.js 2.0を試してみた
PPTX
Vuejs Angularjs e Reactjs. Veja as diferenças de cada framework!
PDF
Progressive Framework Vue.js 2.0
PDF
Vue js 大型專案架構
Happiness and design
Vue.js for beginners
Vue js and Vue Material
Enjoy the vue.js
Why Vue.js?
Vue 2.0 + Vuex Router & Vuex at Vue.js
Vue.js
Pneumobilia vs portal vein gas
Vue 淺談前端建置工具
Javascript MVVM with Vue.JS
Vue.js
Vue.js is boring - and that's a good thing
從改寫後台 jQuery 開始的 Vue.js 宣告式渲染
An Introduction to Vuejs
Vue.js 2.0を試してみた
Vuejs Angularjs e Reactjs. Veja as diferenças de cada framework!
Progressive Framework Vue.js 2.0
Vue js 大型專案架構
Ad

Similar to Making Turbolinks work with Vue.js: Fast server-generated pages with reactive front-end components (20)

PPTX
Revive- a Single page application framework
PDF
Between a SPA and a JAMstack: Building Web Sites with Nuxt/Vue, Strapi and wh...
PDF
Meet VueJs
PDF
Room with a Vue - Introduction to Vue.js
PDF
Easy Decoupled Sitebuilding with GraphQL and Next.js
PDF
Backbone.js with React Views - Server Rendering, Virtual DOM, and More!
PDF
How to Build ToDo App with Vue 3 + TypeScript
PDF
I Heard React Was Good
PDF
Andy Bosch - JavaServer Faces in the cloud
DOCX
Creating an nuget package for EPiServer
PPTX
JOIN 2022: Patching 3rd party software Like a boss
PDF
Drupal point of vue
PDF
AngularJS Toronto: Ng babel+webpack
PDF
Webpack DevTalk
PDF
Modern Web Application Development Workflow - web2day 2014
PDF
Introduction to ReactJS and Redux
PPTX
Getting Started with React v16
PDF
Using RequireJS with CakePHP
PDF
Dandelion 0.10.0
Revive- a Single page application framework
Between a SPA and a JAMstack: Building Web Sites with Nuxt/Vue, Strapi and wh...
Meet VueJs
Room with a Vue - Introduction to Vue.js
Easy Decoupled Sitebuilding with GraphQL and Next.js
Backbone.js with React Views - Server Rendering, Virtual DOM, and More!
How to Build ToDo App with Vue 3 + TypeScript
I Heard React Was Good
Andy Bosch - JavaServer Faces in the cloud
Creating an nuget package for EPiServer
JOIN 2022: Patching 3rd party software Like a boss
Drupal point of vue
AngularJS Toronto: Ng babel+webpack
Webpack DevTalk
Modern Web Application Development Workflow - web2day 2014
Introduction to ReactJS and Redux
Getting Started with React v16
Using RequireJS with CakePHP
Dandelion 0.10.0

Recently uploaded (20)

PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Big Data Technologies - Introduction.pptx
PDF
Approach and Philosophy of On baking technology
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Machine learning based COVID-19 study performance prediction
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
Spectral efficient network and resource selection model in 5G networks
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Empathic Computing: Creating Shared Understanding
Big Data Technologies - Introduction.pptx
Approach and Philosophy of On baking technology
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Programs and apps: productivity, graphics, security and other tools
Machine learning based COVID-19 study performance prediction
Mobile App Security Testing_ A Comprehensive Guide.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Digital-Transformation-Roadmap-for-Companies.pptx
MIND Revenue Release Quarter 2 2025 Press Release
The AUB Centre for AI in Media Proposal.docx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Building Integrated photovoltaic BIPV_UPV.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Review of recent advances in non-invasive hemoglobin estimation
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
“AI and Expert System Decision Support & Business Intelligence Systems”

Making Turbolinks work with Vue.js: Fast server-generated pages with reactive front-end components