SlideShare ist ein Scribd-Unternehmen logo
1 von 18
Downloaden Sie, um offline zu lesen
Abusing Javascript to
speedup mobile web sites.
Mobile browsers are
     dog slow
Only if they are used to render web
sites designed for desktop browsers.

One code for any browser and
device is actually a dream.

Bad code tends to have more impact
on mobile browsers.
Radio networks are
       slow
The main issue is not speed but
latency.

4 Mb downloaded over a single
request: 2 seconds.

Same data downloaded as 20 small
files: 8 seconds.
A 304 reply code is nearly as bad as
a 200

404 replies are rarely cached. Kill
them all.

Proper caching of anything cacheable
is required

Don't overestimate the browser cache
and HTTP keep-alive.
HTML5 cache
         manifest
Doesn't bring much over proper HTTP caching
for online apps.

Everything in the manifest is preloaded even
when useless for the current page. Double-
sided sword.

Requests from a cached page have no referrer.

No granularity: everything depends on the
freshness of the manifest.
Mobile browsers have
   unpredicable caching
         strategy


Even on the same operating system

iOS 4.1 on iPhone 3G doesn't cache
some tiny content that could really
be cached. And that the same OS on
other devices does.
JavaScript to the
     rescue!
Slower may feel
       faster
Mobile devices have small screens.

Load visible content first, and use XHR to
load the rest.

Don't wait until the user scrolls, though.
Latency + tendency to scroll and zoom on
mobile devices would make the page feel
slow.

Provide feedback.
JS + HTTP caching
   = not so bad

Don't repeat yourself: use static JS to
render common, static fragments.

Use XHR to render dynamic parts that
are not immediately visible.

Different parts can have different
expiration.
HTTP cache is quite
  unpredictable
No control over actual eviction.

Might feel good, even for large
requests, until everything is evicted.

The server controls the cache, not
the client (which could come in
handy to avoid inconsistencies).
Localstorage is the
     real shit
Seamlessly keeps over 2.5 Mb of data
per domain.

Mostly persistent.

Provides a flexible client-controlled
cache for any resource.

Trivial to implement.
if (window.localStorage["geoapi_js-v5"]) {
 window.eval(window.localStorage["geoapi_js-v5"]);
} else {
 var xhr = new XMLHttpRequest;
 xhr.onreadystatechange = function() {
  if (this.readyState != 4) {
    return;
  }
  if (this.status != 200) {
    alert("Erreur reseau: " + this.status);
    return;
  }
  try {
    window.localStorage["geoapi_js-v5"] = this.responseText;
  } catch (e) { }
  window.eval(this.responseText);
 };
 xhr.open("GET", "geoapi-v5.js", true);
 xhr.send();
}
Client-side
fragment caching
Dramatically improves performance of a
non-AJAXified page with minor changes.

Use localstorage to store common
fragments.

Tell the server about known fragments so
that only identifiers from the previous
page are sent, in place of the actual
content.
<!doctype html>
<html>
<head>
 <title>Transparent client-side fragment cache demo</title>
</head>
<body>
<!--fragment navbar-290d996311209f1897516b2caa2cc611-->
 <nav>
   Navigation bar
 </nav>
<!--/fragment-->
<!--fragment ads-bd779001f9cad4bfb74e563eb6bbf5c5-->
 <div id="ads">
   Ads
 </div>
<!--/fragment-->
 <section id="hey">
   I ain't no <a href="/">fragment</a>!
 </section>
 <script src="disco.js"></script>
</body>
</html>
<section id="hey">
   I ain't no <a href="/">fragment</a>!
 </section>


gets dynamically rewritten as:


 <section id="hey">
   I ain't no <a href="/?
_fragments=navbar-290d996311209f1897516b2caa2cc611+ads-
bd779001f9cad4bfb74e563eb6bbf5c5">fragment</a>!
 </section>
<!doctype html>
<html>
<head>
 <title>Transparent client-side fragment cache demo</title>
</head>
<body>
<!--cached navbar-290d996311209f1897516b2caa2cc611-->
<!--cached ads-bd779001f9cad4bfb74e563eb6bbf5c5-->
 <section id="hey">
   I ain't no <a href="/">fragment</a>!
 </section>
 <script src="disco.js"></script>
</body>
</html>
http://00f.net/2010/09/22/
 transparent-client-side-
     fragment-cache/
Frank
@jedisct1

Weitere ähnliche Inhalte

Was ist angesagt?

Mongo performance tuning: tips and tricks
Mongo performance tuning: tips and tricksMongo performance tuning: tips and tricks
Mongo performance tuning: tips and tricksVladimir Malyk
 
DDoS: Practical Survival Guide
DDoS: Practical Survival GuideDDoS: Practical Survival Guide
DDoS: Practical Survival GuideHLL
 
MongoDB Memory Management Demystified
MongoDB Memory Management DemystifiedMongoDB Memory Management Demystified
MongoDB Memory Management DemystifiedMongoDB
 
Breaking the Oracle Tie; High Performance OLTP and Analytics Using MongoDB
Breaking the Oracle Tie; High Performance OLTP and Analytics Using MongoDBBreaking the Oracle Tie; High Performance OLTP and Analytics Using MongoDB
Breaking the Oracle Tie; High Performance OLTP and Analytics Using MongoDBMongoDB
 
MongoDB performance tuning and load testing, NOSQL Now! 2013 Conference prese...
MongoDB performance tuning and load testing, NOSQL Now! 2013 Conference prese...MongoDB performance tuning and load testing, NOSQL Now! 2013 Conference prese...
MongoDB performance tuning and load testing, NOSQL Now! 2013 Conference prese...ronwarshawsky
 
Observability tips for HAProxy
Observability tips for HAProxyObservability tips for HAProxy
Observability tips for HAProxyWilly Tarreau
 
Systems Introspection
Systems IntrospectionSystems Introspection
Systems IntrospectionAndrew Howden
 
Webinar slides: How to Secure MongoDB with ClusterControl
Webinar slides: How to Secure MongoDB with ClusterControlWebinar slides: How to Secure MongoDB with ClusterControl
Webinar slides: How to Secure MongoDB with ClusterControlSeveralnines
 
Scaling with mongo db - SF Mongo User Group 7-19-2011
Scaling with mongo db - SF Mongo User Group 7-19-2011Scaling with mongo db - SF Mongo User Group 7-19-2011
Scaling with mongo db - SF Mongo User Group 7-19-2011Jared Rosoff
 
Real time web: is there a life without socket.io and node.js?
Real time web: is there a life without socket.io and node.js?Real time web: is there a life without socket.io and node.js?
Real time web: is there a life without socket.io and node.js?Eduard Trayan
 
MongoDB Hacks of Frustration
MongoDB Hacks of FrustrationMongoDB Hacks of Frustration
MongoDB Hacks of FrustrationMongoDB
 
Distributed computing in browsers as client side attack
Distributed computing in browsers as client side attackDistributed computing in browsers as client side attack
Distributed computing in browsers as client side attackIvan Novikov
 
HAProxy as Egress Controller
HAProxy as Egress ControllerHAProxy as Egress Controller
HAProxy as Egress ControllerJulien Pivotto
 
HTTP 2.0 Why, How and When
HTTP 2.0 Why, How and WhenHTTP 2.0 Why, How and When
HTTP 2.0 Why, How and WhenCodemotion
 
Webinar slides "Building Real-Time Collaborative Web Applications"
Webinar slides "Building Real-Time Collaborative Web Applications"Webinar slides "Building Real-Time Collaborative Web Applications"
Webinar slides "Building Real-Time Collaborative Web Applications"Sachin Katariya
 

Was ist angesagt? (18)

Mongo performance tuning: tips and tricks
Mongo performance tuning: tips and tricksMongo performance tuning: tips and tricks
Mongo performance tuning: tips and tricks
 
DDoS: Practical Survival Guide
DDoS: Practical Survival GuideDDoS: Practical Survival Guide
DDoS: Practical Survival Guide
 
MongoDB Memory Management Demystified
MongoDB Memory Management DemystifiedMongoDB Memory Management Demystified
MongoDB Memory Management Demystified
 
Breaking the Oracle Tie; High Performance OLTP and Analytics Using MongoDB
Breaking the Oracle Tie; High Performance OLTP and Analytics Using MongoDBBreaking the Oracle Tie; High Performance OLTP and Analytics Using MongoDB
Breaking the Oracle Tie; High Performance OLTP and Analytics Using MongoDB
 
MongoDB performance tuning and load testing, NOSQL Now! 2013 Conference prese...
MongoDB performance tuning and load testing, NOSQL Now! 2013 Conference prese...MongoDB performance tuning and load testing, NOSQL Now! 2013 Conference prese...
MongoDB performance tuning and load testing, NOSQL Now! 2013 Conference prese...
 
Observability tips for HAProxy
Observability tips for HAProxyObservability tips for HAProxy
Observability tips for HAProxy
 
Systems Introspection
Systems IntrospectionSystems Introspection
Systems Introspection
 
Web acceleration mechanics
Web acceleration mechanicsWeb acceleration mechanics
Web acceleration mechanics
 
E forensic series
E forensic seriesE forensic series
E forensic series
 
Time series databases
Time series databasesTime series databases
Time series databases
 
Webinar slides: How to Secure MongoDB with ClusterControl
Webinar slides: How to Secure MongoDB with ClusterControlWebinar slides: How to Secure MongoDB with ClusterControl
Webinar slides: How to Secure MongoDB with ClusterControl
 
Scaling with mongo db - SF Mongo User Group 7-19-2011
Scaling with mongo db - SF Mongo User Group 7-19-2011Scaling with mongo db - SF Mongo User Group 7-19-2011
Scaling with mongo db - SF Mongo User Group 7-19-2011
 
Real time web: is there a life without socket.io and node.js?
Real time web: is there a life without socket.io and node.js?Real time web: is there a life without socket.io and node.js?
Real time web: is there a life without socket.io and node.js?
 
MongoDB Hacks of Frustration
MongoDB Hacks of FrustrationMongoDB Hacks of Frustration
MongoDB Hacks of Frustration
 
Distributed computing in browsers as client side attack
Distributed computing in browsers as client side attackDistributed computing in browsers as client side attack
Distributed computing in browsers as client side attack
 
HAProxy as Egress Controller
HAProxy as Egress ControllerHAProxy as Egress Controller
HAProxy as Egress Controller
 
HTTP 2.0 Why, How and When
HTTP 2.0 Why, How and WhenHTTP 2.0 Why, How and When
HTTP 2.0 Why, How and When
 
Webinar slides "Building Real-Time Collaborative Web Applications"
Webinar slides "Building Real-Time Collaborative Web Applications"Webinar slides "Building Real-Time Collaborative Web Applications"
Webinar slides "Building Real-Time Collaborative Web Applications"
 

Ähnlich wie Abusing Javascript to speedup mobile web sites

improve website performance
improve website performanceimprove website performance
improve website performanceamit Sinha
 
Your browser, your storage (extended version)
Your browser, your storage (extended version)Your browser, your storage (extended version)
Your browser, your storage (extended version)Francesco Fullone
 
The 5 most common reasons for a slow WordPress site and how to fix them
The 5 most common reasons for a slow WordPress site and how to fix themThe 5 most common reasons for a slow WordPress site and how to fix them
The 5 most common reasons for a slow WordPress site and how to fix themOtto Kekäläinen
 
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...Otto Kekäläinen
 
Krug Fat Client
Krug Fat ClientKrug Fat Client
Krug Fat ClientPaul Klipp
 
Bt0070 operating systems 2
Bt0070 operating systems  2Bt0070 operating systems  2
Bt0070 operating systems 2Techglyphs
 
Web Speed And Scalability
Web Speed And ScalabilityWeb Speed And Scalability
Web Speed And ScalabilityJason Ragsdale
 
Web Performance in the Age of HTTP/2 - FEDay Conference, Guangzhou, China 19/...
Web Performance in the Age of HTTP/2 - FEDay Conference, Guangzhou, China 19/...Web Performance in the Age of HTTP/2 - FEDay Conference, Guangzhou, China 19/...
Web Performance in the Age of HTTP/2 - FEDay Conference, Guangzhou, China 19/...Holger Bartel
 
Startups to Scale
Startups to ScaleStartups to Scale
Startups to Scaleguest73ced5
 
77739818 troubleshooting-web-logic-103
77739818 troubleshooting-web-logic-10377739818 troubleshooting-web-logic-103
77739818 troubleshooting-web-logic-103shashank_ibm
 
Real-Time with Flowdock
Real-Time with FlowdockReal-Time with Flowdock
Real-Time with FlowdockFlowdock
 
Persistent Offline Storage White
Persistent Offline Storage WhitePersistent Offline Storage White
Persistent Offline Storage WhiteAlexei White
 
Joomla! Performance on Steroids
Joomla! Performance on SteroidsJoomla! Performance on Steroids
Joomla! Performance on SteroidsSiteGround.com
 
Building great mobile apps: Somethings you might want to know
Building great mobile apps: Somethings you might want to knowBuilding great mobile apps: Somethings you might want to know
Building great mobile apps: Somethings you might want to knowshwetank
 

Ähnlich wie Abusing Javascript to speedup mobile web sites (20)

your browser, my storage
your browser, my storageyour browser, my storage
your browser, my storage
 
improve website performance
improve website performanceimprove website performance
improve website performance
 
Your browser, your storage (extended version)
Your browser, your storage (extended version)Your browser, your storage (extended version)
Your browser, your storage (extended version)
 
The 5 most common reasons for a slow WordPress site and how to fix them
The 5 most common reasons for a slow WordPress site and how to fix themThe 5 most common reasons for a slow WordPress site and how to fix them
The 5 most common reasons for a slow WordPress site and how to fix them
 
Caching By Nyros Developer
Caching By Nyros DeveloperCaching By Nyros Developer
Caching By Nyros Developer
 
Mobile Web
Mobile WebMobile Web
Mobile Web
 
your browser, your storage
your browser, your storageyour browser, your storage
your browser, your storage
 
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
 
Krug Fat Client
Krug Fat ClientKrug Fat Client
Krug Fat Client
 
Ror caching
Ror cachingRor caching
Ror caching
 
Bt0070 operating systems 2
Bt0070 operating systems  2Bt0070 operating systems  2
Bt0070 operating systems 2
 
Web Speed And Scalability
Web Speed And ScalabilityWeb Speed And Scalability
Web Speed And Scalability
 
Web Performance in the Age of HTTP/2 - FEDay Conference, Guangzhou, China 19/...
Web Performance in the Age of HTTP/2 - FEDay Conference, Guangzhou, China 19/...Web Performance in the Age of HTTP/2 - FEDay Conference, Guangzhou, China 19/...
Web Performance in the Age of HTTP/2 - FEDay Conference, Guangzhou, China 19/...
 
Your browser, my storage
Your browser, my storageYour browser, my storage
Your browser, my storage
 
Startups to Scale
Startups to ScaleStartups to Scale
Startups to Scale
 
77739818 troubleshooting-web-logic-103
77739818 troubleshooting-web-logic-10377739818 troubleshooting-web-logic-103
77739818 troubleshooting-web-logic-103
 
Real-Time with Flowdock
Real-Time with FlowdockReal-Time with Flowdock
Real-Time with Flowdock
 
Persistent Offline Storage White
Persistent Offline Storage WhitePersistent Offline Storage White
Persistent Offline Storage White
 
Joomla! Performance on Steroids
Joomla! Performance on SteroidsJoomla! Performance on Steroids
Joomla! Performance on Steroids
 
Building great mobile apps: Somethings you might want to know
Building great mobile apps: Somethings you might want to knowBuilding great mobile apps: Somethings you might want to know
Building great mobile apps: Somethings you might want to know
 

Mehr von Frank Denis

El Passo - Privacy-preserving single sign on
El Passo - Privacy-preserving single sign onEl Passo - Privacy-preserving single sign on
El Passo - Privacy-preserving single sign onFrank Denis
 
Improving password-based authentication
Improving password-based authenticationImproving password-based authentication
Improving password-based authenticationFrank Denis
 
This domain name will self-destruct tomorrow
This domain name will self-destruct tomorrowThis domain name will self-destruct tomorrow
This domain name will self-destruct tomorrowFrank Denis
 
An introduction to Pincaster
An introduction to PincasterAn introduction to Pincaster
An introduction to PincasterFrank Denis
 
Redis - (nosqlfr meetup #2)
Redis - (nosqlfr meetup #2) Redis - (nosqlfr meetup #2)
Redis - (nosqlfr meetup #2) Frank Denis
 

Mehr von Frank Denis (6)

El Passo - Privacy-preserving single sign on
El Passo - Privacy-preserving single sign onEl Passo - Privacy-preserving single sign on
El Passo - Privacy-preserving single sign on
 
Improving password-based authentication
Improving password-based authenticationImproving password-based authentication
Improving password-based authentication
 
This domain name will self-destruct tomorrow
This domain name will self-destruct tomorrowThis domain name will self-destruct tomorrow
This domain name will self-destruct tomorrow
 
An introduction to Pincaster
An introduction to PincasterAn introduction to Pincaster
An introduction to Pincaster
 
Graphs
GraphsGraphs
Graphs
 
Redis - (nosqlfr meetup #2)
Redis - (nosqlfr meetup #2) Redis - (nosqlfr meetup #2)
Redis - (nosqlfr meetup #2)
 

Kürzlich hochgeladen

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Kürzlich hochgeladen (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Abusing Javascript to speedup mobile web sites

  • 1. Abusing Javascript to speedup mobile web sites.
  • 2. Mobile browsers are dog slow Only if they are used to render web sites designed for desktop browsers. One code for any browser and device is actually a dream. Bad code tends to have more impact on mobile browsers.
  • 3. Radio networks are slow The main issue is not speed but latency. 4 Mb downloaded over a single request: 2 seconds. Same data downloaded as 20 small files: 8 seconds.
  • 4. A 304 reply code is nearly as bad as a 200 404 replies are rarely cached. Kill them all. Proper caching of anything cacheable is required Don't overestimate the browser cache and HTTP keep-alive.
  • 5. HTML5 cache manifest Doesn't bring much over proper HTTP caching for online apps. Everything in the manifest is preloaded even when useless for the current page. Double- sided sword. Requests from a cached page have no referrer. No granularity: everything depends on the freshness of the manifest.
  • 6. Mobile browsers have unpredicable caching strategy Even on the same operating system iOS 4.1 on iPhone 3G doesn't cache some tiny content that could really be cached. And that the same OS on other devices does.
  • 8. Slower may feel faster Mobile devices have small screens. Load visible content first, and use XHR to load the rest. Don't wait until the user scrolls, though. Latency + tendency to scroll and zoom on mobile devices would make the page feel slow. Provide feedback.
  • 9. JS + HTTP caching = not so bad Don't repeat yourself: use static JS to render common, static fragments. Use XHR to render dynamic parts that are not immediately visible. Different parts can have different expiration.
  • 10. HTTP cache is quite unpredictable No control over actual eviction. Might feel good, even for large requests, until everything is evicted. The server controls the cache, not the client (which could come in handy to avoid inconsistencies).
  • 11. Localstorage is the real shit Seamlessly keeps over 2.5 Mb of data per domain. Mostly persistent. Provides a flexible client-controlled cache for any resource. Trivial to implement.
  • 12. if (window.localStorage["geoapi_js-v5"]) {  window.eval(window.localStorage["geoapi_js-v5"]); } else {  var xhr = new XMLHttpRequest;  xhr.onreadystatechange = function() {   if (this.readyState != 4) {     return;   }   if (this.status != 200) {     alert("Erreur reseau: " + this.status);     return;   }   try {     window.localStorage["geoapi_js-v5"] = this.responseText;   } catch (e) { }   window.eval(this.responseText);  };  xhr.open("GET", "geoapi-v5.js", true);  xhr.send(); }
  • 13. Client-side fragment caching Dramatically improves performance of a non-AJAXified page with minor changes. Use localstorage to store common fragments. Tell the server about known fragments so that only identifiers from the previous page are sent, in place of the actual content.
  • 14. <!doctype html> <html> <head> <title>Transparent client-side fragment cache demo</title> </head> <body> <!--fragment navbar-290d996311209f1897516b2caa2cc611--> <nav> Navigation bar </nav> <!--/fragment--> <!--fragment ads-bd779001f9cad4bfb74e563eb6bbf5c5--> <div id="ads"> Ads </div> <!--/fragment--> <section id="hey"> I ain't no <a href="/">fragment</a>! </section> <script src="disco.js"></script> </body> </html>
  • 15. <section id="hey"> I ain't no <a href="/">fragment</a>! </section> gets dynamically rewritten as: <section id="hey"> I ain't no <a href="/? _fragments=navbar-290d996311209f1897516b2caa2cc611+ads- bd779001f9cad4bfb74e563eb6bbf5c5">fragment</a>! </section>
  • 16. <!doctype html> <html> <head> <title>Transparent client-side fragment cache demo</title> </head> <body> <!--cached navbar-290d996311209f1897516b2caa2cc611--> <!--cached ads-bd779001f9cad4bfb74e563eb6bbf5c5--> <section id="hey"> I ain't no <a href="/">fragment</a>! </section> <script src="disco.js"></script> </body> </html>