SlideShare a Scribd company logo
1 of 18
Download to read offline
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

More Related Content

What's hot

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
 

What's hot (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"
 

Similar to 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
 

Similar to 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
 

More from 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
 

More from 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)
 

Recently uploaded

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 

Recently uploaded (20)

Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 

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>