Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
FSTO: Re-evaluating Front-end Peformance Best P...
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
benvinegar
November 15, 2015
Programming
1.1k
9
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
FSTO: Re-evaluating Front-end Peformance Best Practices
Full Stack Toronto 2015
benvinegar
November 15, 2015
More Decks by benvinegar
See All by benvinegar
Getting the most out of JavaScript errors
benvinegar
1
380
JavaScript Error Reporting (and Why We Can't Have Nice Things)
benvinegar
0
260
Re-evaluating Front-end Performance Best Practices
benvinegar
15
1.7k
Other Decks in Programming
See All in Programming
フィードバックで育てるAI開発
kotaminato
1
120
言語を使う側から、作る側へ。 自作 Lisp で得た新たな気づき。
andpad
0
130
「正の参照」と 「負の導出」で組む ハーネスエンジニアリング
cottpan
1
140
トークンをケチるな、設計しろ:GitHub Copilotを賢く使うコンテキスト戦略
ochtum
0
320
壊れたパーサから始める関数型設計と構成的なパーサ #fp_matsuri
raiga0310
2
330
吝嗇家のためのAI活用 / AI development for miser - ChatGPT + Issue Driven Development
tooppoo
0
190
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
2.8k
Laravelで学ぶ Webアプリケーションチューニング入門/web_application_tuning_101
hanhan1978
4
920
技術記事、 専門家としてのプログラマ、 言語化
mizchi
14
7.5k
act1-costs.pdf
sumedhbala
0
240
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
360k
信頼性について考えてみる(SRE NEXT 2026 miniLT)
hayama17
0
200
Featured
See All Featured
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
62
45k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
What's in a price? How to price your products and services
michaelherold
247
13k
How to Think Like a Performance Engineer
csswizardry
28
2.7k
Deep Space Network (abreviated)
tonyrice
0
230
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
Being A Developer After 40
akosma
91
590k
The Cost Of JavaScript in 2023
addyosmani
55
10k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
350
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
390
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
Transcript
re-evaluating front-end performance best practices
@bentlegen
None
http://getsentry.com
car·go cult
ccccccejlfevnigejevgjkglrc hibhjrtcjlngnfblfb cargo cult science
cargo cult web performance
how did we get here?
deprecated books 2007 2009 2010
stackoverflow answers
analysis tools
analysis tools 2014 2013
practices on live websites
conference talks
today’s agenda • hostname sharding • for-loop array length caching
• dynamic script insertion
hostname sharding
in the beginning (HTTP 1.0)
with more connections 2 4 8 www www www
with hostname sharding 2 2 2 www www1, www2 www1
www2 www3 www4
still common Website # Static Hosts plus.google.com 4 tumblr.com 4
alibaba.com 4 theverge.com 4 ebay.com 6 businessinsider.com 6 netflix.com 11!
None
not a big deal anymore
browser connections/origin Browser # HTTP / origin Chrome 42 6
Firefox 37 8 Safari 7 6 IE 8, 9 6 IE 10 8 IE 11 13 bit.ly/rprf-bscope
chrome caps parallel image requests at 10 anyways bit.ly/rprf-bscope
rise of https stalled/ proxy negotiation dns lookup connection +
tls/ssl time-to- first-byte download tls/ssl handshake
and http/2 will make all this irrelevant anyways
“2 domains for non- [HTTP2] modern browsers” – Souders in
2013 bit.ly/rprf-2domains
etsy case study • 4 image domains → 2 •
50-80 ms faster for image heavy pages • 30-50 ms faster overall • up to 500ms faster on mobile bit.ly/rprf-etsy
the web’s moving on Website # Static Hosts netflix.com* 1
nytimes.com 1 youtube.com 2 twitter.com 2 facebook.com 2 pinterest.com 2 bbc.co.uk 2 etsy.com 3
looping
specifically array length caching in for loops
for (var i = 0, len = arr.length; i <
len; i++) { // do stuff } for (var i = 0; i < arr.length; i++) { // do stuff } vs
None
None
None
does it still hold?
cache vs no cache Chrome 42 Firefox 37 Safari 7
IE9+ IE8 ops/second (normalized), bigger is better cache no cache 78%
V8 (and other browsers) recognize this pattern bit.ly/rprf-v8opt
None
uncached version
cached version
“we should start assuming that our code is optimized” -
Vyacheslav Egorov, V8 bit.ly/rprf-v8opt
if you can trivially optimize it, the browser (probably) can
too
mobile disagrees, a little Chrome 41 (Android 5.1) Firefox 34
(Android 5.1) Safari (iOS 8) ops / second (normalized), bigger is better cache no cache 95%
new in es6 for (x of arr) { … }
dynamic script insertion
blocking scripts (2009) <script src=“/vendor.js”></script> <script src=“/app.js"></script> <img src=“/logo.gif”/> <link
rel=“stylesheet” type=“text/css” href=“/app.css”/> <iframe src=“/widget.html”/> vendor.js finishes app.js starts img, css, iframe
dynamic script insertion <script> var script = document.createElement('script'); script.src =
'/app.js'; document.getElementsByTagName('head')[0] .appendChild(script); </script> all load in parallel
None
None
you’ve used this • analytics: GA, Mixpanel, Chartbeat, Wordpress •
widgets: Disqus, Facebook Comments • JS module loaders: RequireJS, LabJS • script managers: Google Tag Manager, Segment
small problem: CSS Object Model
CSS Object Model (CCSOM) <link rel="stylesheet" type="text/css" href="/ main.css"/> <script>
window.getComputedStyle(document.body).margin; </script> can’t execute until CSS ready
CSSOM + dynamic script insertion <link rel="stylesheet" type="text/css" href="/ main.css"/>
<script> var script = document.createElement('script'); script.src = '/app.js'; document.getElementsByTagName('head')[0] .appendChild(script); </script> can’t execute until CSS ready
dynamic script insertion scripts execute inline scripts can’t execute until
CSSOM ready; downloading is delayed
blocking 2nd script downloads after 1st executes 1st script preloaded
1st script executes
blocking with Chrome 1st and 2nd script preloaded 1st and
2nd script execute (blocked for CSSOM)
2014
3rd option: async attribute <script async src="/app.js"></script>
ideal: async attribute scripts execute before CSS finished all 3
resources download in parallel
we should probably start using async
new: GA + async attr
closing thoughts
don’t always believe what you read on the internet
benchmark your own stuff
benchmark your own stuff every few years
always bet on browsers (and JS engines)
thanks
acknowledgements • performance research: Steve Souders, Ilya Grigorik, Guy Podjarny,
Vyacheslav Egorov, Jonathan Klein, Paul Irish, Nicholas Zakas • photos: Christian Junker, André Hofmeister, “My aim is true” • me: Ben Vinegar (@bentlegen) • Sentry plug: http://getsentry.com