SlideShare a Scribd company logo
1 of 53
Download to read offline
RICH AND
SNAPPY APPS
 (   NO SCALING
     REQUIRED          )
       BY AMY HOY
    AND THOMAS FUCHS
 HTTP://SLASH7.COM/COMPANY
@amyhoy   @thomasfuchs
PERF
ORMA
 NCE
“In A/B tests, we tried delaying the
page in increments of 100 milliseconds
and found that even very small delays
would result in substantial and costly
drops in revenue.”
                  Greg Linden, Amazon.com
Back-End
              10%




Front-End
   90%
                 (NOT SCIENTIFIC)
225+ PAGES
<!DOCTYPE “xmlns:xsl=’http://www.w3.org/1999/XSŁ
Transform’”><html xmlns:java_code=“xalan://
gov.blahblah.build.Utils2”><head><META http-equiv=“Content-
Type” content=“text/html; charset=UTF-8”><title>Blahblah -
Home
</title><!--SYSTEM DEFINED METADATA--><META content=“IE=7”
http-equiv=“X-UA-Compatible”><META NAME=“CMS Document Id”
CONTENT=“120186”><META NAME=“dc.title” CONTENT=“NASA -
Home”><META NAME=“dc.format” CONTENT=“text/html”><META
NAME=“dc.date.modified” CONTENT=“2009-06-27”><META
NAME=“dc.language” CONTENT=“en”><META NAME=“dc.publisher”
CONTENT=“Foobar”><META NAME=“dc.description” CONTENT=“”><META
NAME=“dc.identifier” CONTENT=“http://www.blahblah.gov/home/
index.html”><!--USER DEFINED METADATA--><META NAME=“dc.subject”
CONTENT=“”><title>Blahblah -
Home
</title><!--Standard Includes--><script src=“/js/
191918main_browser_message.js” type=“text/javascript”
language=“javascript”></script>
<link type=“text/css” rel=“stylesheet” href=“/css/
205608main_allmodules_homepage.css”><script
language=“javascript” type=“text/javascript” src=“/
templateimages/redesign/browser/js/conditionalBrowser.js”></
script>
DOM MONSTER
 BOOKMARKLET
1. LOAD-TIME
2. RUN-TIME
3. FAKING IT
LOAD-TIME #1
 EXPIRATION
  HEADERS
caching headers are good
 but expiration is wrong
LOAD-TIME #2
CONCATENATION
not so good   optimized
http://getsprockets.org
//= require <prototype>
      //= require “css”
      //= require “fx”




library_path/lib/prototype.js       src/css.js   src/fx.js


                     1          2         3



                   concatenated.js
YUI Compressor




        concatenated.js   concatenated.min.js




http://developer.yahoo.com/yui/compressor/
LOAD-TIME #3
    GZIP
.
prototype
    .
138k




             80k




                          24k



Original   Minified   Minified+GZIP




  5.7X compression
more than a second
 faster on a 1MBit
    connection
1. LOAD-TIME
2. RUN-TIME
3. FAKING IT
RUN-TIME #1
   HTML
COMPLEXITY
source: http://tr.im/ffreflow
RUN-TIME #2
    INLINE
FUNCTION CALLS
function methodCall(){
  function square(n){ return n*n };
  var i=10000, sum = 0;
  while(i--) sum += square(i);
}

function inlinedMethod(){
  var i=10000, sum = 0;
  while(i--) sum += i*i;
}
function methodCall(){
  function square(n){ return n*n };
  var i=10000, sum = 0;
  while(i--) sum += square(i);
}

function inlinedMethod(){
  var i=10000, sum = 0;
  while(i--) sum += i*i;
}
function methodCall(){
  function square(n){ return n*n };
  var i=10000, sum = 0;
  while(i--) sum += square(i);
}

function inlinedMethod(){
  var i=10000, sum = 0;
  while(i--) sum += i*i;
}
methodCall() inlinedMethod()

    0.410s        0.150s


    0.056s        0.045s


uhm, ahh, hmm†    0.128s


    0.027s        0.016s
IE8 THROWS THIS
WARNING AFTER 1SEC
RUN-TIME #3
EMBRACE THE
 LANGUAGE
function literals(){
  var a = [], o = {};
}

function classic(){
  var a = new Array, o = new Object;
}
classic()   literals()

  0.291s      0.265s


  0.020s      0.016s


  0.220s      0.185s


  0.024s      0.010s
var string = ‘2’;

function implicit(){
  return 1 * string;
}

function explicit(){
  return parseInt(string);
}
explicit()   implicit()

  0.044s       0.054s


  0.012s       0.004s


  0.015s       0.036s


  0.080s       0.060s
RUN-TIME #4
GET RID OF LOOPS
function normalLoop(){
  var i=60, j=0;
  while(i--) j++;
}
function unrolledLoop(){
  var j=0;
  j++; j++; j++; j++; j++;   j++;
  j++; j++; j++; j++; j++;   j++;
  j++; j++; j++; j++; j++;   j++;
  j++; j++; j++; j++; j++;   j++;
  j++; j++; j++; j++; j++;   j++;
  j++; j++; j++; j++; j++;   j++;
  j++; j++; j++; j++; j++;   j++;
  j++; j++; j++; j++; j++;   j++;
  j++; j++; j++; j++; j++;   j++;
  j++; j++; j++; j++; j++;   j++;
}
normalLoop() unrolledLoop()

   0.023s        0.010s


   0.003s        0.001s


   0.032s        0.015s


   0.005s        0.001s
BEWARE OF
   ENGINE
DIFFERENCES
function test(){
  return 1 * ‘2’;
}

alert(test.toString());
function test(){
  return 1 * ‘2’;
}

alert(test.toString());
function test(){
  return 1 * ‘2’;
}

alert(test.toString());
1. LOAD-TIME
2. RUN-TIME
3. FAKING IT
... AND GRANT ME
 THE SERENITY TO
ACCEPT THE THINGS
     I CAN'T
USERS WAIT FOR
5-8 SECONDS BEFORE
    GIVING UP                          †




        †Nah, F., "A study on tolerable waiting time: how long are Web users willing to wait?"
        Behaviour & Information Technology 23, no. 3 (2004): 153-163.
OR UP TO HALF A
  MINUTE WITH A
PROGRESS FEEDBACK
More in
http://jsrocks.com
Q&A
 RICH AND SNAPPY APPS
       BY AMY HOY
   AND THOMAS FUCHS
HTTP://SLASH7.COM/COMPANY

More Related Content

What's hot

Ugly code
Ugly codeUgly code
Ugly code
Odd-e
 
What is row level isolation on cassandra
What is row level isolation on cassandraWhat is row level isolation on cassandra
What is row level isolation on cassandra
Kazutaka Tomita
 
Bytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreterBytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreter
akaptur
 
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!..."A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
akaptur
 

What's hot (20)

Javascript ES6 generators
Javascript ES6 generatorsJavascript ES6 generators
Javascript ES6 generators
 
project3
project3project3
project3
 
如何「畫圖」寫測試 - RxJS Marble Test
如何「畫圖」寫測試 - RxJS Marble Test如何「畫圖」寫測試 - RxJS Marble Test
如何「畫圖」寫測試 - RxJS Marble Test
 
Ugly code
Ugly codeUgly code
Ugly code
 
What is row level isolation on cassandra
What is row level isolation on cassandraWhat is row level isolation on cassandra
What is row level isolation on cassandra
 
Bytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreterBytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreter
 
Python meetup: coroutines, event loops, and non-blocking I/O
Python meetup: coroutines, event loops, and non-blocking I/OPython meetup: coroutines, event loops, and non-blocking I/O
Python meetup: coroutines, event loops, and non-blocking I/O
 
The Ring programming language version 1.5.3 book - Part 89 of 184
The Ring programming language version 1.5.3 book - Part 89 of 184The Ring programming language version 1.5.3 book - Part 89 of 184
The Ring programming language version 1.5.3 book - Part 89 of 184
 
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!..."A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
 
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
 
PyconKR 2018 Deep dive into Coroutine
PyconKR 2018 Deep dive into CoroutinePyconKR 2018 Deep dive into Coroutine
PyconKR 2018 Deep dive into Coroutine
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
 
Numerical Methods with Computer Programming
Numerical Methods with Computer ProgrammingNumerical Methods with Computer Programming
Numerical Methods with Computer Programming
 
ES6(ES2015) is beautiful
ES6(ES2015) is beautifulES6(ES2015) is beautiful
ES6(ES2015) is beautiful
 
You will learn RxJS in 2017
You will learn RxJS in 2017You will learn RxJS in 2017
You will learn RxJS in 2017
 
QA Fest 2019. Saar Rachamim. Developing Tools, While Testing
QA Fest 2019. Saar Rachamim. Developing Tools, While TestingQA Fest 2019. Saar Rachamim. Developing Tools, While Testing
QA Fest 2019. Saar Rachamim. Developing Tools, While Testing
 
The Ring programming language version 1.4 book - Part 21 of 30
The Ring programming language version 1.4 book - Part 21 of 30The Ring programming language version 1.4 book - Part 21 of 30
The Ring programming language version 1.4 book - Part 21 of 30
 
Sangam 19 - Successful Applications on Autonomous
Sangam 19 - Successful Applications on AutonomousSangam 19 - Successful Applications on Autonomous
Sangam 19 - Successful Applications on Autonomous
 
Object oriented JavaScript
Object oriented JavaScriptObject oriented JavaScript
Object oriented JavaScript
 
Introducing to Asynchronous Programming
Introducing to Asynchronous  ProgrammingIntroducing to Asynchronous  Programming
Introducing to Asynchronous Programming
 

Similar to Rich and Snappy Apps (No Scaling Required)

Deterministic simulation testing
Deterministic simulation testingDeterministic simulation testing
Deterministic simulation testing
FoundationDB
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2
rohassanie
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
Dmitry Buzdin
 
Orsiso
OrsisoOrsiso
Orsiso
e27
 

Similar to Rich and Snappy Apps (No Scaling Required) (20)

The Ring programming language version 1.8 book - Part 51 of 202
The Ring programming language version 1.8 book - Part 51 of 202The Ring programming language version 1.8 book - Part 51 of 202
The Ring programming language version 1.8 book - Part 51 of 202
 
2013 - Nate Abele: HTTP ALL THE THINGS: Simplificando aplicaciones respetando...
2013 - Nate Abele: HTTP ALL THE THINGS: Simplificando aplicaciones respetando...2013 - Nate Abele: HTTP ALL THE THINGS: Simplificando aplicaciones respetando...
2013 - Nate Abele: HTTP ALL THE THINGS: Simplificando aplicaciones respetando...
 
Performance and stability testing \w Gatling
Performance and stability testing \w GatlingPerformance and stability testing \w Gatling
Performance and stability testing \w Gatling
 
Cpp programs
Cpp programsCpp programs
Cpp programs
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
 
Deterministic simulation testing
Deterministic simulation testingDeterministic simulation testing
Deterministic simulation testing
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2
 
Performance
PerformancePerformance
Performance
 
C++ file
C++ fileC++ file
C++ file
 
C++ file
C++ fileC++ file
C++ file
 
The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Load Data Fast!
Load Data Fast!Load Data Fast!
Load Data Fast!
 
TDC2018SP | Trilha Kotlin - Programacao assincrona utilizando Coroutines
TDC2018SP | Trilha Kotlin - Programacao assincrona utilizando CoroutinesTDC2018SP | Trilha Kotlin - Programacao assincrona utilizando Coroutines
TDC2018SP | Trilha Kotlin - Programacao assincrona utilizando Coroutines
 
Programação assíncrona utilizando Coroutines
Programação assíncrona utilizando CoroutinesProgramação assíncrona utilizando Coroutines
Programação assíncrona utilizando Coroutines
 
Orsiso
OrsisoOrsiso
Orsiso
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
 
Operator overloading2
Operator overloading2Operator overloading2
Operator overloading2
 
Non Blocking I/O for Everyone with RxJava
Non Blocking I/O for Everyone with RxJavaNon Blocking I/O for Everyone with RxJava
Non Blocking I/O for Everyone with RxJava
 
Is writing performant code too expensive?
Is writing performant code too expensive? Is writing performant code too expensive?
Is writing performant code too expensive?
 

More from Thomas Fuchs

Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2KZepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Thomas Fuchs
 

More from Thomas Fuchs (8)

Zepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-FrameworksZepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-Frameworks
 
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2KZepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K
 
I Can't Believe It's Not Flash
I Can't Believe It's Not FlashI Can't Believe It's Not Flash
I Can't Believe It's Not Flash
 
Prototype & Scriptaculous
Prototype  & ScriptaculousPrototype  & Scriptaculous
Prototype & Scriptaculous
 
Textorize
TextorizeTextorize
Textorize
 
Adventures In JavaScript Testing
Adventures In JavaScript TestingAdventures In JavaScript Testing
Adventures In JavaScript Testing
 
Ruby On Rails Introduction
Ruby On Rails IntroductionRuby On Rails Introduction
Ruby On Rails Introduction
 
Twistori Tech
Twistori TechTwistori Tech
Twistori Tech
 

Recently uploaded

Models in Deira 0567006274 Deira Call girl Service
Models in Deira 0567006274 Deira Call girl ServiceModels in Deira 0567006274 Deira Call girl Service
Models in Deira 0567006274 Deira Call girl Service
Monica Sydney
 
Abortion pills in Saudi RIYADH (+919707899604 } Get Cytotec
Abortion pills in Saudi RIYADH (+919707899604 } Get CytotecAbortion pills in Saudi RIYADH (+919707899604 } Get Cytotec
Abortion pills in Saudi RIYADH (+919707899604 } Get Cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
Dubai Call girls Service 0524076003 Call girls in Dubai
Dubai Call girls Service 0524076003 Call girls in DubaiDubai Call girls Service 0524076003 Call girls in Dubai
Dubai Call girls Service 0524076003 Call girls in Dubai
Monica Sydney
 
Just Call Vip call girls Palghar Escorts ☎️8617370543 Two shot with one girl ...
Just Call Vip call girls Palghar Escorts ☎️8617370543 Two shot with one girl ...Just Call Vip call girls Palghar Escorts ☎️8617370543 Two shot with one girl ...
Just Call Vip call girls Palghar Escorts ☎️8617370543 Two shot with one girl ...
Nitya salvi
 

Recently uploaded (20)

Models in Deira 0567006274 Deira Call girl Service
Models in Deira 0567006274 Deira Call girl ServiceModels in Deira 0567006274 Deira Call girl Service
Models in Deira 0567006274 Deira Call girl Service
 
Hire 💕 8617370543 Mirzapur Call Girls Service Call Girls Agency
Hire 💕 8617370543 Mirzapur Call Girls Service Call Girls AgencyHire 💕 8617370543 Mirzapur Call Girls Service Call Girls Agency
Hire 💕 8617370543 Mirzapur Call Girls Service Call Girls Agency
 
Abortion pills in Saudi RIYADH (+919707899604 } Get Cytotec
Abortion pills in Saudi RIYADH (+919707899604 } Get CytotecAbortion pills in Saudi RIYADH (+919707899604 } Get Cytotec
Abortion pills in Saudi RIYADH (+919707899604 } Get Cytotec
 
Bhubaneswar🌹Call Girls Kalpana Mesuem ❤Komal 9777949614 💟 Full Trusted CALL ...
Bhubaneswar🌹Call Girls Kalpana Mesuem  ❤Komal 9777949614 💟 Full Trusted CALL ...Bhubaneswar🌹Call Girls Kalpana Mesuem  ❤Komal 9777949614 💟 Full Trusted CALL ...
Bhubaneswar🌹Call Girls Kalpana Mesuem ❤Komal 9777949614 💟 Full Trusted CALL ...
 
Dubai Call girls Service 0524076003 Call girls in Dubai
Dubai Call girls Service 0524076003 Call girls in DubaiDubai Call girls Service 0524076003 Call girls in Dubai
Dubai Call girls Service 0524076003 Call girls in Dubai
 
Deira call girls 0507330913 Call girls in Deira
Deira call girls 0507330913  Call girls in DeiraDeira call girls 0507330913  Call girls in Deira
Deira call girls 0507330913 Call girls in Deira
 
Call Girls in Kollam - 9332606886 Our call girls are sure to provide you with...
Call Girls in Kollam - 9332606886 Our call girls are sure to provide you with...Call Girls in Kollam - 9332606886 Our call girls are sure to provide you with...
Call Girls in Kollam - 9332606886 Our call girls are sure to provide you with...
 
Turbhe Female Escorts 09167354423 Turbhe Escorts,Call Girls In Turbhe
Turbhe Female Escorts 09167354423  Turbhe Escorts,Call Girls In TurbheTurbhe Female Escorts 09167354423  Turbhe Escorts,Call Girls In Turbhe
Turbhe Female Escorts 09167354423 Turbhe Escorts,Call Girls In Turbhe
 
Call girls Service Berhampur - 9332606886 Our call girls are sure to provide ...
Call girls Service Berhampur - 9332606886 Our call girls are sure to provide ...Call girls Service Berhampur - 9332606886 Our call girls are sure to provide ...
Call girls Service Berhampur - 9332606886 Our call girls are sure to provide ...
 
Hire 💕 8617370543 Auraiya Call Girls Service Call Girls Agency
Hire 💕 8617370543 Auraiya Call Girls Service Call Girls AgencyHire 💕 8617370543 Auraiya Call Girls Service Call Girls Agency
Hire 💕 8617370543 Auraiya Call Girls Service Call Girls Agency
 
Call 8617370543 Sangli Call girls with real photos and phone numbers
Call 8617370543 Sangli Call girls with real photos and phone numbersCall 8617370543 Sangli Call girls with real photos and phone numbers
Call 8617370543 Sangli Call girls with real photos and phone numbers
 
Just Call Vip call girls Palghar Escorts ☎️8617370543 Two shot with one girl ...
Just Call Vip call girls Palghar Escorts ☎️8617370543 Two shot with one girl ...Just Call Vip call girls Palghar Escorts ☎️8617370543 Two shot with one girl ...
Just Call Vip call girls Palghar Escorts ☎️8617370543 Two shot with one girl ...
 
Jann Mardenborough's Better Half in Racing and Life
Jann Mardenborough's Better Half in Racing and LifeJann Mardenborough's Better Half in Racing and Life
Jann Mardenborough's Better Half in Racing and Life
 
Satara call girl 8617370543♥️ call girls in satara escort service
Satara call girl 8617370543♥️ call girls in satara escort serviceSatara call girl 8617370543♥️ call girls in satara escort service
Satara call girl 8617370543♥️ call girls in satara escort service
 
Foreigner Call Girls Mahim WhatsApp +91-9833363713, Full Night Service
Foreigner Call Girls Mahim WhatsApp +91-9833363713, Full Night ServiceForeigner Call Girls Mahim WhatsApp +91-9833363713, Full Night Service
Foreigner Call Girls Mahim WhatsApp +91-9833363713, Full Night Service
 
Vip Call Girls Bhubaneswar 🐱‍🏍 9777949614 Independent Escorts Service Bhubane...
Vip Call Girls Bhubaneswar 🐱‍🏍 9777949614 Independent Escorts Service Bhubane...Vip Call Girls Bhubaneswar 🐱‍🏍 9777949614 Independent Escorts Service Bhubane...
Vip Call Girls Bhubaneswar 🐱‍🏍 9777949614 Independent Escorts Service Bhubane...
 
Deira Call girls 0507330913 Call girls in Deira
Deira Call girls 0507330913 Call girls in DeiraDeira Call girls 0507330913 Call girls in Deira
Deira Call girls 0507330913 Call girls in Deira
 
Call Girls Kozhikode - 9332606886 Our call girls are sure to provide you with...
Call Girls Kozhikode - 9332606886 Our call girls are sure to provide you with...Call Girls Kozhikode - 9332606886 Our call girls are sure to provide you with...
Call Girls Kozhikode - 9332606886 Our call girls are sure to provide you with...
 
Dubai Call Girls 0556255850 Call girls in Dubai
Dubai Call Girls 0556255850 Call girls in DubaiDubai Call Girls 0556255850 Call girls in Dubai
Dubai Call Girls 0556255850 Call girls in Dubai
 
Call Girls Bhubaneswar 9777949614 call me Independent Escort Service Bhubaneswar
Call Girls Bhubaneswar 9777949614 call me Independent Escort Service BhubaneswarCall Girls Bhubaneswar 9777949614 call me Independent Escort Service Bhubaneswar
Call Girls Bhubaneswar 9777949614 call me Independent Escort Service Bhubaneswar
 

Rich and Snappy Apps (No Scaling Required)