SlideShare una empresa de Scribd logo
1 de 66
Descargar para leer sin conexión
progressive
enhancement for
JS apps
Garann Means @garannm🚀 🚀
why this talk?
a little case study
🚀 tons and tons of JS
🚀 real-time
🚀 collaborative
🚀 offline capabilities*
🚀 fallback: a textarea
the fix: progressive
enhancement
2003-2008
2003-2008
🚀 “let’s use JS for everything!”
2003-2008
🚀 “let’s use JS for everything!”
🚀 “what, people have JS turned off?”
2003-2008
🚀 “let’s use JS for everything!”
🚀 “what, people have JS turned off?”
🚀 “what, browser support is inconsistent?”
2003-2008
🚀 “let’s use JS for everything!”
🚀 “what, people have JS turned off?”
🚀 “what, browser support is inconsistent?”
🚀 “who cares, our customers are cutting edge”
2003-2008
🚀 “let’s use JS for everything!”
🚀 “what, people have JS turned off?”
🚀 “what, browser support is inconsistent?”
🚀 “who cares, our customers are cutting edge”
🚀 from yesterday: “if you’re seeing a broken
experience, your environment is broken”
2003-2008
🚀 “let’s use JS for everything!”
🚀 “what, people have JS turned off?”
🚀 “what, browser support is inconsistent?”
🚀 “who cares, our customers are cutting edge”
🚀 from yesterday: “if you’re seeing a broken
experience, your environment is broken”
🚀 “oh weird our business failed”
progressive enhancement:
🚀 deliver a usable baseline experience
🚀 offer an upgraded experience to more powerful
browsers
vs. graceful degradation
🚀 code for the most powerful clients
🚀 problem? deliver a lesser experience
why’d we switch?
🚀 degradation is harder to plan accurately
🚀 degradation makes things even slower for less
powerful clients
🚀 hope for the best, plan for the worst
this is a best practice
on the front-end
JS apps
JS apps
🚀 “oh, but this isn’t for people who don’t have
JavaScript”
JS apps
🚀 “oh, but this isn’t for people who don’t have
JavaScript”
🚀 “..or people returning to the site”
JS apps
🚀 “oh, but this isn’t for people who don’t have
JavaScript”
🚀 “..or people returning to the site”
🚀 “..or people going through a tunnel on a train”
*ahem*
have we learned nothing?
🚀 obviously we want the best experience possible
🚀 this is the internet; “possible” changes
🚀 brittle expectations of our users means a worse
experience
🚀 for everyone
what to do with
that thinking?
a method
🚀 build servers as if every client is text-only
🚀 build clients as if the internet will disappear
tomorrow
🚀 expect people not to use the app the way you
expected
some simple principles
🚀 state is shared between client and server
🚀 the client takes responsibility for state offline
🚀 and attempts to sync when it comes online
🚀 actions, by default, occur on both client and
server
“computer, enhance!”
“computer, enhance!”
🚀 is JS available?
🚀 great, run the client-side app
“computer, enhance!”
🚀 is JS available?
🚀 great, run the client-side app
🚀 are we online?
🚀 great, send updates to the server
“computer, enhance!”
🚀 is JS available?
🚀 great, run the client-side app
🚀 are we online?
🚀 great, send updates to the server
🚀 client and server aren’t in sync?
🚀 no problem, put them in sync
sharing state is more
than just sharing
state
this is a state
$( “#form-step-2” ).show();
(this is a shared state)
body.registration-step-2 #form-step-2 {
display: block;
}
this one isn’t being shared
$( “#form-step-2” ).show();
state runs the app
🚀 interface changes
🚀 fetching data
🚀 app logic updates the state
🚀 state changes trigger everything else
we can still do this
$( “#form-step-2” ).show();
it just works differently
$( “#form-step-2” )[
registration_step == 2 ?
“show” :
“hide”
]();
protip: CSS is an
observer by default
same on the server
app.get( “/register/:step?”,
function( req, res ) {
var step =
req.params.step || registration_step;
res.render(
“reg_step_” + step, registration_data );
});
question: where is
registration_step set?
glad you asked!
🚀 updates about state are separate from updates
as a result of state
🚀 data updates are chunked
🚀 state updates are instant (if possible)
separate state updates
make syncing easier
let’s say our user goes offline
> my_app.state.registration_step
1
then clicks submit
$( “#form-step-1” ).on( “submit”, function(){
set_registration_step( 2 );
return false;
});
it’s fine
> my_app.state.registration_step
2
everything handled
function set_registration_step( step ) {
my_app.state.registration_step = step;
update_state( “registration_step_” + step );
var data = get_data( step - 1 );
save_data( ( step - 1 ), data );
$( “form-step-” + step ).show();
}
and stored
function save_data( step, data ) {
db.put( data, “registration_” + step,
function( err, response ) {
if ( err ) {
show_error( “Data not saved!” );
}
});
}
note: plan your storage
🚀 small apps may be able to be stored entirely
🚀 only the current workflow in large apps may be
able to be stored
🚀 the more changes happen offline, the less room
for potentially used data
if you accept data,
you have to hang
onto it
how does the client know it’s
offline?
🚀 poll for server updates
🚀 catch a socket error
🚀 sending data via normal XHR
🚀 wait for an error saving
hope for the best,
plan for the worst
function update_state( state ) {
state_cache.push( state )
var req = $.ajax({
type: “POST”,
url: “/update_state”,
data: state_cache
}).done( function() {
state_cache = [];
}).fail( function( xhr, err ) {
if ( err == “timeout” ) start_heartbeat();
});
}
offline, the client is on
its own
how do know you’re back?
🚀 try it
🚀 navigator.onLine
🚀 probably some sort of heartbeat
🚀 no matter your strategy
and then:
🚀 send client’s current state
🚀 follow a defined path from server’s current state
to client’s
🚀 or send specific steps from the client
🚀 sync server data with client
tl;dr, offline is scary
so let’s talk actions
<input type=”submit” value=”Continue ☞” />
<!-- NO NO NO NO NO NO NO NO NO NO NO
<div id=”save-step-1”>Continue ☞</div> -->
actions in the interface
🚀 never trigger actions directly
🚀 actions are triggered by state changes
🚀 state changes update client and server
🚀 then the action itself occurs
this guy
$( “#form-step-2” ).show();
and this one
$( “#form-step-2” ).save();
saving (for example)
🚀 fetches user-entered data from the interface
🚀 stores it in an application variable
🚀 adds it to the local data store
🚀 notifies the server that a save occurred
🚀 syncs data
..then the server
🚀 default: fetches user-entered data from the client
🚀 enhanced: syncs with client DB
🚀 stores it in an application variable
🚀 adds it to the backend data store
🚀 notifies any other connected clients that there are
changes
same thing happens
on both sides, why?
other connected clients &
reloads
🚀 fetches user-entered data from the server
🚀 stores it in an application variable
🚀 adds it to its local data store
🚀 updates its interface
if JS disappears
🚀 we use HTML behaviors (links, buttons) to skip
right to the server step
🚀 concurrent users receive immediately-expiring
data
we need state reflected in:
🚀 client and server variables, ofc
🚀 the URL
🚀 the CSS
tada: it’s progressive!
🚀 our server has a version of the app and can
render its interface
🚀 client side can continue without the server, in
case we go offline
🚀 real-time communication and multiple
concurrent users follow the same pattern
our app is now
🚀 usable by multiple clients
🚀 in multiple locations
🚀 and easier to continue extending
🚀 by layering functionality, as with progressive
enhancement
thanks!
@garannm garann@gmail.com🚀 🚀

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

React.js and Redux overview
React.js and Redux overviewReact.js and Redux overview
React.js and Redux overview
 
React state managmenet with Redux
React state managmenet with ReduxReact state managmenet with Redux
React state managmenet with Redux
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
 
Intro to ReactJS
Intro to ReactJSIntro to ReactJS
Intro to ReactJS
 
Introduction to react and redux
Introduction to react and reduxIntroduction to react and redux
Introduction to react and redux
 
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
 
React, Flux and a little bit of Redux
React, Flux and a little bit of ReduxReact, Flux and a little bit of Redux
React, Flux and a little bit of Redux
 
Let's Redux!
Let's Redux!Let's Redux!
Let's Redux!
 
Let's discover React and Redux with TypeScript
Let's discover React and Redux with TypeScriptLet's discover React and Redux with TypeScript
Let's discover React and Redux with TypeScript
 
React & redux
React & reduxReact & redux
React & redux
 
Academy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & ToolingAcademy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & Tooling
 
React JS and Redux
React JS and ReduxReact JS and Redux
React JS and Redux
 
Getting started with ReactJS
Getting started with ReactJSGetting started with ReactJS
Getting started with ReactJS
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.js
 
Attribute actions
Attribute actionsAttribute actions
Attribute actions
 
Better React state management with Redux
Better React state management with ReduxBetter React state management with Redux
Better React state management with Redux
 
JOSA TechTalks - Better Web Apps with React and Redux
JOSA TechTalks - Better Web Apps with React and ReduxJOSA TechTalks - Better Web Apps with React and Redux
JOSA TechTalks - Better Web Apps with React and Redux
 
Wicket Live on Stage
Wicket Live on StageWicket Live on Stage
Wicket Live on Stage
 
React / Redux Architectures
React / Redux ArchitecturesReact / Redux Architectures
React / Redux Architectures
 
React, Redux, ES2015 by Max Petruck
React, Redux, ES2015   by Max PetruckReact, Redux, ES2015   by Max Petruck
React, Redux, ES2015 by Max Petruck
 

Similar a Progressive Enhancement for JavaScript Apps

Automated Performance Testing With J Meter And Maven
Automated  Performance  Testing With  J Meter And  MavenAutomated  Performance  Testing With  J Meter And  Maven
Automated Performance Testing With J Meter And Maven
PerconaPerformance
 
Socket applications
Socket applicationsSocket applications
Socket applications
João Moura
 

Similar a Progressive Enhancement for JavaScript Apps (20)

A Journey with React
A Journey with ReactA Journey with React
A Journey with React
 
"Progressive Web Apps" by Riza Fahmi (Hacktiv8)
"Progressive Web Apps" by Riza Fahmi	(Hacktiv8)"Progressive Web Apps" by Riza Fahmi	(Hacktiv8)
"Progressive Web Apps" by Riza Fahmi (Hacktiv8)
 
Progressive Web Apps. What, why and how
Progressive Web Apps. What, why and howProgressive Web Apps. What, why and how
Progressive Web Apps. What, why and how
 
Engineering Velocity @indeed eng presented on Sept 24 2014 at Beyond Agile
Engineering Velocity @indeed eng presented on Sept 24 2014 at Beyond AgileEngineering Velocity @indeed eng presented on Sept 24 2014 at Beyond Agile
Engineering Velocity @indeed eng presented on Sept 24 2014 at Beyond Agile
 
3 Tips to Deliver Fast Performance Across Mobile Web
3 Tips to Deliver Fast Performance Across Mobile Web3 Tips to Deliver Fast Performance Across Mobile Web
3 Tips to Deliver Fast Performance Across Mobile Web
 
Google I/O State Of Ajax
Google I/O State Of AjaxGoogle I/O State Of Ajax
Google I/O State Of Ajax
 
Continuous Deployment: The Dirty Details
Continuous Deployment: The Dirty DetailsContinuous Deployment: The Dirty Details
Continuous Deployment: The Dirty Details
 
Plone Interactivity
Plone InteractivityPlone Interactivity
Plone Interactivity
 
Having Fun with Play
Having Fun with PlayHaving Fun with Play
Having Fun with Play
 
Web is the New Mobile: Building Progressive Web Apps - Erica Stanley - Codemo...
Web is the New Mobile: Building Progressive Web Apps - Erica Stanley - Codemo...Web is the New Mobile: Building Progressive Web Apps - Erica Stanley - Codemo...
Web is the New Mobile: Building Progressive Web Apps - Erica Stanley - Codemo...
 
Automated Performance Testing With J Meter And Maven
Automated  Performance  Testing With  J Meter And  MavenAutomated  Performance  Testing With  J Meter And  Maven
Automated Performance Testing With J Meter And Maven
 
Socket applications
Socket applicationsSocket applications
Socket applications
 
Web apps without internet
Web apps without internetWeb apps without internet
Web apps without internet
 
I Know It Was MEAN, But I Cut the Cord to LAMP Anyway
I Know It Was MEAN, But I Cut the Cord to LAMP AnywayI Know It Was MEAN, But I Cut the Cord to LAMP Anyway
I Know It Was MEAN, But I Cut the Cord to LAMP Anyway
 
More Secrets of JavaScript Libraries
More Secrets of JavaScript LibrariesMore Secrets of JavaScript Libraries
More Secrets of JavaScript Libraries
 
Going web native
Going web nativeGoing web native
Going web native
 
ATAGTR2017 HikeRunner: Load Test Framework
ATAGTR2017 HikeRunner: Load Test FrameworkATAGTR2017 HikeRunner: Load Test Framework
ATAGTR2017 HikeRunner: Load Test Framework
 
Developing for LinkedIn's Application Platform
Developing for LinkedIn's Application PlatformDeveloping for LinkedIn's Application Platform
Developing for LinkedIn's Application Platform
 
Intro To Django
Intro To DjangoIntro To Django
Intro To Django
 
RateMyArea - interesting rails bits
RateMyArea - interesting rails bitsRateMyArea - interesting rails bits
RateMyArea - interesting rails bits
 

Más de Codemotion

Más de Codemotion (20)

Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
 
Pompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending storyPompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending story
 
Pastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storiaPastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storia
 
Pennisi - Essere Richard Altwasser
Pennisi - Essere Richard AltwasserPennisi - Essere Richard Altwasser
Pennisi - Essere Richard Altwasser
 
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
 
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
 
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
 
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 - Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
 
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
 
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
 
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
 
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
 
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
 
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
 
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
 
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
 
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
 
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
 
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
 
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
 

Último

在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
ydyuyu
 
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
nirzagarg
 
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
nilamkumrai
 
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
imonikaupta
 
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
nirzagarg
 
Thalassery Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call G...
Thalassery Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call G...Thalassery Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call G...
Thalassery Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call G...
Call Girls In Delhi Whatsup 9873940964 Enjoy Unlimited Pleasure
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
JOHNBEBONYAP1
 
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
@Chandigarh #call #Girls 9053900678 @Call #Girls in @Punjab 9053900678
 

Último (20)

2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
 
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
 
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
 
Microsoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftMicrosoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck Microsoft
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
 
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
 
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
 
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
 
Thalassery Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call G...
Thalassery Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call G...Thalassery Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call G...
Thalassery Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call G...
 
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
 
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
 

Progressive Enhancement for JavaScript Apps

  • 3. a little case study 🚀 tons and tons of JS 🚀 real-time 🚀 collaborative 🚀 offline capabilities* 🚀 fallback: a textarea
  • 6. 2003-2008 🚀 “let’s use JS for everything!”
  • 7. 2003-2008 🚀 “let’s use JS for everything!” 🚀 “what, people have JS turned off?”
  • 8. 2003-2008 🚀 “let’s use JS for everything!” 🚀 “what, people have JS turned off?” 🚀 “what, browser support is inconsistent?”
  • 9. 2003-2008 🚀 “let’s use JS for everything!” 🚀 “what, people have JS turned off?” 🚀 “what, browser support is inconsistent?” 🚀 “who cares, our customers are cutting edge”
  • 10. 2003-2008 🚀 “let’s use JS for everything!” 🚀 “what, people have JS turned off?” 🚀 “what, browser support is inconsistent?” 🚀 “who cares, our customers are cutting edge” 🚀 from yesterday: “if you’re seeing a broken experience, your environment is broken”
  • 11. 2003-2008 🚀 “let’s use JS for everything!” 🚀 “what, people have JS turned off?” 🚀 “what, browser support is inconsistent?” 🚀 “who cares, our customers are cutting edge” 🚀 from yesterday: “if you’re seeing a broken experience, your environment is broken” 🚀 “oh weird our business failed”
  • 12. progressive enhancement: 🚀 deliver a usable baseline experience 🚀 offer an upgraded experience to more powerful browsers
  • 13. vs. graceful degradation 🚀 code for the most powerful clients 🚀 problem? deliver a lesser experience
  • 14. why’d we switch? 🚀 degradation is harder to plan accurately 🚀 degradation makes things even slower for less powerful clients 🚀 hope for the best, plan for the worst
  • 15. this is a best practice on the front-end
  • 17. JS apps 🚀 “oh, but this isn’t for people who don’t have JavaScript”
  • 18. JS apps 🚀 “oh, but this isn’t for people who don’t have JavaScript” 🚀 “..or people returning to the site”
  • 19. JS apps 🚀 “oh, but this isn’t for people who don’t have JavaScript” 🚀 “..or people returning to the site” 🚀 “..or people going through a tunnel on a train”
  • 21. have we learned nothing? 🚀 obviously we want the best experience possible 🚀 this is the internet; “possible” changes 🚀 brittle expectations of our users means a worse experience 🚀 for everyone
  • 22. what to do with that thinking?
  • 23. a method 🚀 build servers as if every client is text-only 🚀 build clients as if the internet will disappear tomorrow 🚀 expect people not to use the app the way you expected
  • 24. some simple principles 🚀 state is shared between client and server 🚀 the client takes responsibility for state offline 🚀 and attempts to sync when it comes online 🚀 actions, by default, occur on both client and server
  • 26. “computer, enhance!” 🚀 is JS available? 🚀 great, run the client-side app
  • 27. “computer, enhance!” 🚀 is JS available? 🚀 great, run the client-side app 🚀 are we online? 🚀 great, send updates to the server
  • 28. “computer, enhance!” 🚀 is JS available? 🚀 great, run the client-side app 🚀 are we online? 🚀 great, send updates to the server 🚀 client and server aren’t in sync? 🚀 no problem, put them in sync
  • 29. sharing state is more than just sharing state
  • 30. this is a state $( “#form-step-2” ).show();
  • 31. (this is a shared state) body.registration-step-2 #form-step-2 { display: block; }
  • 32. this one isn’t being shared $( “#form-step-2” ).show();
  • 33. state runs the app 🚀 interface changes 🚀 fetching data 🚀 app logic updates the state 🚀 state changes trigger everything else
  • 34. we can still do this $( “#form-step-2” ).show();
  • 35. it just works differently $( “#form-step-2” )[ registration_step == 2 ? “show” : “hide” ]();
  • 36. protip: CSS is an observer by default
  • 37. same on the server app.get( “/register/:step?”, function( req, res ) { var step = req.params.step || registration_step; res.render( “reg_step_” + step, registration_data ); });
  • 39. glad you asked! 🚀 updates about state are separate from updates as a result of state 🚀 data updates are chunked 🚀 state updates are instant (if possible)
  • 40. separate state updates make syncing easier
  • 41. let’s say our user goes offline > my_app.state.registration_step 1
  • 42. then clicks submit $( “#form-step-1” ).on( “submit”, function(){ set_registration_step( 2 ); return false; });
  • 44. everything handled function set_registration_step( step ) { my_app.state.registration_step = step; update_state( “registration_step_” + step ); var data = get_data( step - 1 ); save_data( ( step - 1 ), data ); $( “form-step-” + step ).show(); }
  • 45. and stored function save_data( step, data ) { db.put( data, “registration_” + step, function( err, response ) { if ( err ) { show_error( “Data not saved!” ); } }); }
  • 46. note: plan your storage 🚀 small apps may be able to be stored entirely 🚀 only the current workflow in large apps may be able to be stored 🚀 the more changes happen offline, the less room for potentially used data
  • 47. if you accept data, you have to hang onto it
  • 48. how does the client know it’s offline? 🚀 poll for server updates 🚀 catch a socket error 🚀 sending data via normal XHR 🚀 wait for an error saving
  • 49. hope for the best, plan for the worst function update_state( state ) { state_cache.push( state ) var req = $.ajax({ type: “POST”, url: “/update_state”, data: state_cache }).done( function() { state_cache = []; }).fail( function( xhr, err ) { if ( err == “timeout” ) start_heartbeat(); }); }
  • 50. offline, the client is on its own
  • 51. how do know you’re back? 🚀 try it 🚀 navigator.onLine 🚀 probably some sort of heartbeat 🚀 no matter your strategy
  • 52. and then: 🚀 send client’s current state 🚀 follow a defined path from server’s current state to client’s 🚀 or send specific steps from the client 🚀 sync server data with client
  • 54. so let’s talk actions <input type=”submit” value=”Continue ☞” /> <!-- NO NO NO NO NO NO NO NO NO NO NO <div id=”save-step-1”>Continue ☞</div> -->
  • 55. actions in the interface 🚀 never trigger actions directly 🚀 actions are triggered by state changes 🚀 state changes update client and server 🚀 then the action itself occurs
  • 57. and this one $( “#form-step-2” ).save();
  • 58. saving (for example) 🚀 fetches user-entered data from the interface 🚀 stores it in an application variable 🚀 adds it to the local data store 🚀 notifies the server that a save occurred 🚀 syncs data
  • 59. ..then the server 🚀 default: fetches user-entered data from the client 🚀 enhanced: syncs with client DB 🚀 stores it in an application variable 🚀 adds it to the backend data store 🚀 notifies any other connected clients that there are changes
  • 60. same thing happens on both sides, why?
  • 61. other connected clients & reloads 🚀 fetches user-entered data from the server 🚀 stores it in an application variable 🚀 adds it to its local data store 🚀 updates its interface
  • 62. if JS disappears 🚀 we use HTML behaviors (links, buttons) to skip right to the server step 🚀 concurrent users receive immediately-expiring data
  • 63. we need state reflected in: 🚀 client and server variables, ofc 🚀 the URL 🚀 the CSS
  • 64. tada: it’s progressive! 🚀 our server has a version of the app and can render its interface 🚀 client side can continue without the server, in case we go offline 🚀 real-time communication and multiple concurrent users follow the same pattern
  • 65. our app is now 🚀 usable by multiple clients 🚀 in multiple locations 🚀 and easier to continue extending 🚀 by layering functionality, as with progressive enhancement