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
Re-evaluating Front-end Performance Best Practices
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
benvinegar
April 21, 2015
Programming
15
1.6k
Re-evaluating Front-end Performance Best Practices
Fluent 2015
benvinegar
April 21, 2015
Tweet
Share
More Decks by benvinegar
See All by benvinegar
Getting the most out of JavaScript errors
benvinegar
1
360
JavaScript Error Reporting (and Why We Can't Have Nice Things)
benvinegar
0
240
FSTO: Re-evaluating Front-end Peformance Best Practices
benvinegar
9
1.1k
Other Decks in Programming
See All in Programming
HTTPプロトコル正しく理解していますか? 〜かわいい猫と共に学ぼう。ฅ^•ω•^ฅ ニャ〜
hekuchan
2
660
高速開発のためのコード整理術
sutetotanuki
1
320
Architectural Extensions
denyspoltorak
0
220
QAフローを最適化し、品質水準を満たしながらリリースまでの期間を最短化する #RSGT2026
shibayu36
2
3.9k
MDN Web Docs に日本語翻訳でコントリビュート
ohmori_yusuke
0
590
dchart: charts from deck markup
ajstarks
3
970
フロントエンド開発の勘所 -複数事業を経験して見えた判断軸の違い-
heimusu
7
2.6k
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
390
余白を設計しフロントエンド開発を 加速させる
tsukuha
7
2k
AI Agent Dojo #4: watsonx Orchestrate ADK体験
oniak3ibm
PRO
0
130
組織で育むオブザーバビリティ
ryota_hnk
0
140
IFSによる形状設計/デモシーンの魅力 @ 慶應大学SFC
gam0022
1
260
Featured
See All Featured
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
71
Become a Pro
speakerdeck
PRO
31
5.8k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
What's in a price? How to price your products and services
michaelherold
247
13k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.9k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
66
36k
Utilizing Notion as your number one productivity tool
mfonobong
2
200
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
53
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
120
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.3k
Transcript
re-evaluating front-end performance best practices
@bentlegen
None
None
car·go cult
cargo cult web performance
how does it happen?
deprecated … • books • blog posts • best practice
guides • StackOverflow answers • performance analysis tools • practices on live websites • conference talks like this one
the 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-SPDY 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
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%
if you think you’re going to get performance gains from
optimizing for loops you’re gonna have a bad time
dynamic script insertion
<script> var script = document.createElement('script'); script.src = '/app.js'; document.getElementsByTagName('head')[0] .appendChild(script);
</script> vs <script src="/app.js"></script>
None
None
who does 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 type="text/stylesheet" href="/main.css"/> ! ! !
<script> window.getComputedStyle(document.body).margin; </script> can’t execute until CSS ready
CSSOM + dynamic script insertion <link type="text/stylesheet" 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
“Have we been doing it all wrong?” - Ilya Grigorik,
2014 bit.ly/rprf-injected
3rd option: async attribute <script async src="/app.js"></script>
ideal: async attribute both scripts execute all 3 resources download
in parallel
we should probably start using async
None
closing thoughts
don’t always believe what you read on the internet
benchmark your own stuff
benchmark your own stuff every year, apparently
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) • office hours @ 1:30 PM today