SlideShare uma empresa Scribd logo
1 de 41
Check Yourself Before
You Wreck Yourself
Auditing and Improving the Performance of Boomerang
Nic Jansma
njansma@akamai.com
@nicj
Why are we here today?
● Boomerang: an open-source Real User Monitoring
(RUM) third-party library
○ https://github.com/akamai/boomerang
● Why performance matters to us
● Performance Audit
● Improvements!
● Testing, Validation, Protecting against Regressions
Why should you care?
● Do you develop a library that other teams, companies or projects use?
● Do you use a third-party library?
○ Any library that you didn't write
○ They might be packaged in your application’s JavaScript bundle, included via a cross-
origin <script> tag, or injected via a tag manager.
Boss: Developer, please add this fancy new script!
<script async src="//cdn.remarketing.com/js/foo.min.js"></script>
What could go wrong? It’s just one simple line!
<script async src="//cdn.remarketing.com/js/foo.min.js"></script>
That one little line can:
● Cause your page to stop loading
● Slow down other components
● Create incompatibilities with other libraries
● Change from underneath you
● Take total control of your site
What can go wrong?
Boomerang
● 14,000+ mPulse sites
○ > 1 billion page loads a day
● 76,000 - 460,000 sites using open-source boomerang.js (estimate)
https://discuss.httparchive.org/t/who-are-the-top-rum-analytics-providers/
https://trends.builtwith.com/javascript/Boomerang
“Everything should have a value, because everything has a cost” - @tkadlec
How can we judge the cost of a script?
$ ls -al modernizr.js*
-rw-r--r--@ 1 nicjansma staff 92,475 May 30 20:20 modernizr.js
-rw-r--r-- 1 nicjansma staff 32,599 May 30 20:21 modernizr.js.gz
… it’s... cheap???
Evaluating the Cost of a 3rd Party
A third-party’s size (bytes) contributes to the overall Page Weight.
Page Weight is important - it has an effect on how long the page takes to load,
especially on lower-end devices or slower connections.
Lowering the Page Weight can improve load times, so you want to factor the
byte cost of a third-party into your overall Performance Budget.
… but while it’s the easiest way to judge a third party, it’s just one aspect of the
overall cost.
Resource Weight
A 3rd-Party Script’s Lifecycle & Costs
1. Loader Snippet / <script>
2. Download
3. Parse + Compile
4. Initialize
5. Runtime / event handlers
Boomerang Performance Audit
Boomerang Performance Audit
1. Loader Snippet / <script>
2. Download
3. Parse + Compile
4. Initialize
5. Runtime / event handlers
A 3rd-Party Script’s Lifecycle
Critical path!
1. Script tag itself has no cost: <script
src="..."></script>
2. Snippets have a cost (2-10ms on desktop
Chrome):
<script type="text/javascript">
(function() {
var po = document.createElement('script');
po.type = 'text/javascript'; po.async = true;
po.src = 'https://.../foo.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})();
</script>
1. Loader Snippet / <script>
2. Download
3. Parse + Compile
4. Initialize
5. Runtime / event handlers
Boomerang's Loader Snippet
3. Boomerang's Loader Snippet
Completely async and non-blocking
Better than <script async>
Cost: 2-40ms
More expensive than <script>, but
guaranteed to not block
https://akamai.github.io/boomerang/tutorial-loader-snippet.html
1. Loader Snippet / <script>
2. Download
3. Parse + Compile
4. Initialize
5. Runtime / event handlers
A 3rd-Party Script’s Lifecycle
Every byte affects overall page weight.
Critical path?
● External <script> / tag: no (unless sharing
domain)
● Bundled with other components: yes?
Load from a CDN!
The script may load additional resources.
1. Loader Snippet / <script>
2. Download
3. Parse + Compile
4. Initialize
5. Runtime / event handlers
A 3rd-Party Script’s Lifecycle
//requestmap.webperf.tools
1. Loader Snippet / <script>
2. Download
3. Parse + Compile
4. Initialize
5. Runtime / event handlers
A 3rd-Party Script’s Lifecycle
● underscore.js 7 KB
● Google Analytics 14 KB
● moment 16 KB
● jQuery 29 KB
● React 32 KB
● Twitter 34 KB
● Boomerang 47 KB
● Angular 59 KB
● D3 71 KB
1. Loader Snippet / <script>
2. Download
3. Parse + Compile
4. Initialize
5. Runtime / event handlers
Boomerang is built with a plug-in architecture and you
can build smaller builds if you'd prefer.
For example, if you don't need: SPA, XHR, UserTiming
or Error Tracking support Boomerang shrinks from 47
KB to 26 KB.
A 3rd-Party Script’s Lifecycle
1. Loader Snippet / <script>
2. Download
3. Parse + Compile
4. Initialize
5. Runtime / event handlers
A 3rd-Party Script’s Lifecycle
Critical path!
After being fetched, the browser must parse / compile
the (decompressed) JavaScript before it’s executed.
Less bytes = less parse / compile.
● Moment 5 ms 143
KB
● Boomerang 10 ms 188 KB
● Twitter Widget 10 ms 227 KB
● jQuery 11 ms 265
1. Loader Snippet / <script>
2. Download
3. Parse + Compile
4. Initialize
5. Runtime / event handlers
A 3rd-Party Script’s Lifecycle
Critical path!
Many scripts will initialize (do some work) at startup -
create structures, globals, hook events, etc.
● moment 2 ms
● jQuery 9 ms
● Boomerang 10 ms
● Angular 12 ms
● Twitter Widget 20 ms
1. Loader Snippet / <script>
2. Download
3. Parse + Compile
4. Initialize
5. Runtime / event handlers
Critical path!
The library should be there for a reason.
This reason will do work periodically or based
on user interactions.
● SPA framework updating the view after a
route change
● Analytics scripts sending beacons
● Charting library responding to user
interactions
A 3rd-Party Script’s Lifecycle
1. Loader Snippet / <script>
2. Download
3. Parse + Compile
4. Initialize
5. Runtime / event handlers
Boomerang: depending on the site, 10-40ms at
onload
Upwards of 300ms on resource-heavy sites on
low-end devices
A 3rd-Party Script’s Lifecycle
1. Loader Snippet / <script>
2. Download
3. Parse + Compile
4. Initialize
5. Runtime / event handlers
Critical path!
All bold could be done on the main thread
(depending on the browser) and can can cause
Long Tasks.
A 3rd-Party Script’s Lifecycle
1. Loader Snippet / <script>
2. Download
3. Parse + Compile
4. Initialize
5. Runtime / event handlers
A task is work the browser is doing to build the page, such as parsing HTML,
executing JavaScript, or performing layout. This happens on the main thread.
The browser cannot respond to user input (clicking, scrolling, etc) while
executing a task.
Long Tasks are due to complex work that requires more than 50ms of
execution time. i.e. parsing or executing complex JavaScript.
Long Tasks will delay Time to Interactive - the point at which your app is
responsive.
Long Tasks and Time to Interactive
Boomerang’s Performance Audit
https://nicj.net/an-audit-of-boomerangs-performance/
TL;DR boomerang’s 2018 cost (high-end to low-end devices):
1. Loader Snippet 2 - 40 ms
2. Download 188 KB raw / 47 KB gzip (non-blocking)
3. Parse 6 - 47 ms
4. Initialize 3 - 15 ms
5. @onload 10 - 300 ms
6. Beacon 2 - 20 KB
7. Runtime minimal
Tracking improvements @ https://github.com/akamai/boomerang/issues
Performance Audit Tools
Developer tools are your friend!
Profilers can point to opportunities
My advice:
● Take your time
● Get a sense for the overall picture
● Look for extremes - longest
duration, tallest stack
Chrome Lighthouse
developers.google.com
/web/tools/lighthouse/
Evaluating for Performance
RequestMap
requestmap.webperf.tools
WebPagetest
webpagetest.org
3rdParty.io
3rdparty.io
Boomerang’s Performance Audit
https://nicj.net/an-audit-of-boomerangs-performance/
We found room for improvement! Filed 15 issues. Examples:
● ResourceTiming Compression is expensive
● Loader Snippet Performance in Edge
● Breakup plugin creation / initialization to avoid long tasks
● Beacon: Review cookie access
● Beacon: Memory: Node counting is expensive
● Unload beacon size
● Unload Beacon: Memory plugin updating DOM counts
Tracking improvements @ https://github.com/akamai/boomerang/issues
https://nicj.net/boomerang-performance-update/
● New Loader Snippet
● ResourceTiming Optimization
● Removed Debug Messages
● Improved Minification
● Reduced Cookie Size
● Reduced Cookie Access
● Simplified MD5 plugin
● Simplified SPA plugin
● Enabled Brotli for CDN
Boomerang’s Performance Improvements
Using <link rel="preload"> we can load
async and non-blocking without an IFRAME
Reduced 2-40ms to 1ms for browsers that
support Preload!
https://nicj.net/boomerang-performance-update/
● New Loader Snippet
● ResourceTiming Optimization
● Removed Debug Messages
● Improved Minification
● Enabled Brotli for CDN
● Reduced Cookie Size
● Reduced Cookie Access
● Simplified MD5 plugin
● Simplified SPA plugin
Boomerang’s Performance Improvements
Compressing ResourceTiming data was our most
expensive task
Tweaked the algorithm slightly to be slightly-
less-than-perfect for a 4x speedup
Reduced some sites' cost from 100ms to 25ms
or 300ms to 75ms
https://nicj.net/boomerang-performance-update/
● New Loader Snippet
● ResourceTiming Optimization
● Removed Debug Messages
● Improved Minification
● Enabled Brotli for CDN
● Reduced Cookie Size
● Reduced Cookie Access
● Simplified MD5 plugin
● Simplified SPA plugin
We were shipping debug log messages even
though the debug log was disabled (6% saving)
Changed from Uglify2 to Uglify3 (1.3% saving)
Enabled Brotli on the Akamai CDN (11.2% saving)
SPA and MD5 plugins refactored (2.8% saving)
Boomerang’s Performance Improvements
https://nicj.net/boomerang-performance-update/
● New Loader Snippet
● ResourceTiming Optimization
● Removed Debug Messages
● Improved Minification
● Enabled Brotli for CDN
● Reduced Cookie Size
● Reduced Cookie Access
● Simplified MD5 plugin
● Simplified SPA plugin
Boomerang’s Performance Improvements
We set a cookie to track sessions
Changed how we stored some of the data (e.g.
hash instead of a full URL, Base36 instead of
Base10 for numbers): 41% smaller
We were reading/writing constantly during
startup -- simplified our operations from 21 reads
and 8 writes down to 2 reads and 4 writes
https://nicj.net/boomerang-performance-update/
● New Loader Snippet
● ResourceTiming Optimization
● Removed Debug Messages
● Improved Minification
● Enabled Brotli for CDN
● Reduced Cookie Size
● Reduced Cookie Access
● Simplified MD5 plugin
● Simplified SPA plugin
Boomerang’s Performance Improvements
We were using MD5 for hashing and comparing
URLs quickly
This plugin took 8.1 KB and could hash 35,397
URLs/sec
We replaced with the FNV algorithm: 0.34 KB and
113,532 URLs/sec
SPA plugin was simplified and removed
framework-specific support in favor of just
monitoring the window.History object
Boomerang’s Performance Audit
https://nicj.net/boomerang-performance-update/
After fixes:
1. Loader Snippet 2 - 40 ms 1-20 ms (1 ms in modern browsers)
2. Download 188 KB raw / 47 KB gzip 196 KB raw / 47 KB brotli
3. Parse 6 - 47 ms (same)
4. Initialize 3 - 15 ms (same)
5. @onload 10 - 300 ms 5-75 ms
6. Beacon 2 - 20 KB (same)
7. Runtime minimal
Tracking improvements @ https://github.com/akamai/boomerang/issues
Boomerang’s Performance Audit
https://nicj.net/boomerang-performance-update/
Opportunities!
1. Loader Snippet 2 - 40 ms 1-20 ms (1 ms in modern browsers)
2. Download 188 KB raw / 47 KB gzip 196 KB raw / 47 KB brotli
3. Parse 6 - 47 ms (same)
4. Initialize 3 - 15 ms (same)
5. @onload 10 - 300 ms 5-75 ms
6. Beacon 2 - 20 KB (same)
7. Runtime minimal
Tracking improvements @ https://github.com/akamai/boomerang/issues
Continuous, Gradual Improvement
In a mature product with a healthy process you're much more likely to see a 50%
gain come in the form of many 5% gains compounding to get to your goal via
sustained effort and quality control
https://docs.microsoft.com/en-us/archive/blogs/ricom/the-performance-war-win-it-5-at-a-time
Protecting Against Regressions
Boomerang Performance Lab / Test Suite
Simple set of scenarios & metrics we capture each build
Tracks:
● CPU time via headless Profiler
● Counts & Durations via UserTiming marks & measures
● Sizes of code & plugins
https://akamai.github.io/boomerang/tutorial-perf-tests.html
You can capture your script's
own runtime stats, Long
Tasks and JavaScript errors
JavaScript Self Profiling API
Realtime Telemetry
Boss: Developer, please add this fancy new script!
<script async src="//cdn.remarketing.com/js/foo.min.js"></script>
● Perform a light-weight audit
● Do its benefits outweigh its costs?
● Ask if the library has published performance information
● Every third-party should have an owner or “internal champion”
What can you do?
What 3rd Party Scripts Should be Doing...
They should:
● Use a CDN
● Compress resources
● Set caching headers
● Set Timing-Allow-Origin
● Set ACAO
● Support HTTPS
● Support HTTP/2
● Minify
● Have ~100% uptime
Minimal:
● JavaScript size
● Work without yielding
● Network latency
● CPU
● Requests
● Cookies
● DOM changes / additions
● Event hooks
● Global variables
● Patching
● Changes without your permission
No:
● document.write()
● alert() or prompt()
● eval()
● debugger;
● Console messages
● JavaScript errors
● Including other libs
● Redirects
● Known vulnerabilities
3rdParty.io
● https://nicj.net/an-audit-of-boomerangs-performance/
● https://nicj.net/boomerang-performance-update/
● https://github.com/akamai/boomerang/issues
● https://3rdparty.io/
Links
thanks!
nicj.net/talks/
Nic Jansma
njansma@akamai.com
nic@nicj.net
@nicj

Mais conteúdo relacionado

Mais procurados

Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011Ilya Grigorik
 
ZendCon 2015 - DevOps for Small Teams
ZendCon 2015 - DevOps for Small TeamsZendCon 2015 - DevOps for Small Teams
ZendCon 2015 - DevOps for Small TeamsJoe Ferguson
 
Measuring the visual experience of website performance
Measuring the visual experience of website performanceMeasuring the visual experience of website performance
Measuring the visual experience of website performancePatrick Meenan
 
Selecting and deploying automated optimization solutions
Selecting and deploying automated optimization solutionsSelecting and deploying automated optimization solutions
Selecting and deploying automated optimization solutionsPatrick Meenan
 
Guide you to optimize and speed up your Joomla site quickly
Guide you to optimize and speed up your Joomla site quicklyGuide you to optimize and speed up your Joomla site quickly
Guide you to optimize and speed up your Joomla site quicklyvandon.com.vn
 
Tracking Performance - Velocity NYC 2013
Tracking Performance - Velocity NYC 2013Tracking Performance - Velocity NYC 2013
Tracking Performance - Velocity NYC 2013Patrick Meenan
 
ZendCon 2015 - Laravel Forge: Hello World to Hello Production
ZendCon 2015 - Laravel Forge: Hello World to Hello ProductionZendCon 2015 - Laravel Forge: Hello World to Hello Production
ZendCon 2015 - Laravel Forge: Hello World to Hello ProductionJoe Ferguson
 
Magento on HHVM. Daniel Sloof
Magento on HHVM. Daniel SloofMagento on HHVM. Daniel Sloof
Magento on HHVM. Daniel SloofMeetMagentoNY2014
 
Willing Webcam manual
Willing Webcam manualWilling Webcam manual
Willing Webcam manualwwwilling
 
Hacking Web Performance @ ForwardJS 2017
Hacking Web Performance @ ForwardJS 2017Hacking Web Performance @ ForwardJS 2017
Hacking Web Performance @ ForwardJS 2017Maximiliano Firtman
 
Web Performance Optimization
Web Performance OptimizationWeb Performance Optimization
Web Performance OptimizationPatrick Meenan
 
How webpage loading takes place?
How webpage loading takes place?How webpage loading takes place?
How webpage loading takes place?Abhishek Mitra
 
High Performance JavaScript (Amazon DevCon 2011)
High Performance JavaScript (Amazon DevCon 2011)High Performance JavaScript (Amazon DevCon 2011)
High Performance JavaScript (Amazon DevCon 2011)Nicholas Zakas
 
Performance Of Web Applications On Client Machines
Performance Of Web Applications On Client MachinesPerformance Of Web Applications On Client Machines
Performance Of Web Applications On Client MachinesCurelet Marius
 
Automated Tasks for WordPress
Automated Tasks for WordPressAutomated Tasks for WordPress
Automated Tasks for WordPressJoe Cartonia
 
Apache httpd Reverse Proxy and Tomcat
Apache httpd Reverse Proxy and TomcatApache httpd Reverse Proxy and Tomcat
Apache httpd Reverse Proxy and TomcatJim Jagielski
 
Compile time dependency injection in Play 2.4 with macwire
Compile time dependency injection in Play 2.4 with macwireCompile time dependency injection in Play 2.4 with macwire
Compile time dependency injection in Play 2.4 with macwireyann_s
 

Mais procurados (20)

Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011
 
ZendCon 2015 - DevOps for Small Teams
ZendCon 2015 - DevOps for Small TeamsZendCon 2015 - DevOps for Small Teams
ZendCon 2015 - DevOps for Small Teams
 
Measuring the visual experience of website performance
Measuring the visual experience of website performanceMeasuring the visual experience of website performance
Measuring the visual experience of website performance
 
Selecting and deploying automated optimization solutions
Selecting and deploying automated optimization solutionsSelecting and deploying automated optimization solutions
Selecting and deploying automated optimization solutions
 
Web Leaps Forward
Web Leaps ForwardWeb Leaps Forward
Web Leaps Forward
 
Guide you to optimize and speed up your Joomla site quickly
Guide you to optimize and speed up your Joomla site quicklyGuide you to optimize and speed up your Joomla site quickly
Guide you to optimize and speed up your Joomla site quickly
 
Tracking Performance - Velocity NYC 2013
Tracking Performance - Velocity NYC 2013Tracking Performance - Velocity NYC 2013
Tracking Performance - Velocity NYC 2013
 
ZendCon 2015 - Laravel Forge: Hello World to Hello Production
ZendCon 2015 - Laravel Forge: Hello World to Hello ProductionZendCon 2015 - Laravel Forge: Hello World to Hello Production
ZendCon 2015 - Laravel Forge: Hello World to Hello Production
 
High-Speed HTML5
High-Speed HTML5High-Speed HTML5
High-Speed HTML5
 
Magento on HHVM. Daniel Sloof
Magento on HHVM. Daniel SloofMagento on HHVM. Daniel Sloof
Magento on HHVM. Daniel Sloof
 
Willing Webcam manual
Willing Webcam manualWilling Webcam manual
Willing Webcam manual
 
Hacking Web Performance @ ForwardJS 2017
Hacking Web Performance @ ForwardJS 2017Hacking Web Performance @ ForwardJS 2017
Hacking Web Performance @ ForwardJS 2017
 
Web Performance Optimization
Web Performance OptimizationWeb Performance Optimization
Web Performance Optimization
 
Hacking Web Performance
Hacking Web Performance Hacking Web Performance
Hacking Web Performance
 
How webpage loading takes place?
How webpage loading takes place?How webpage loading takes place?
How webpage loading takes place?
 
High Performance JavaScript (Amazon DevCon 2011)
High Performance JavaScript (Amazon DevCon 2011)High Performance JavaScript (Amazon DevCon 2011)
High Performance JavaScript (Amazon DevCon 2011)
 
Performance Of Web Applications On Client Machines
Performance Of Web Applications On Client MachinesPerformance Of Web Applications On Client Machines
Performance Of Web Applications On Client Machines
 
Automated Tasks for WordPress
Automated Tasks for WordPressAutomated Tasks for WordPress
Automated Tasks for WordPress
 
Apache httpd Reverse Proxy and Tomcat
Apache httpd Reverse Proxy and TomcatApache httpd Reverse Proxy and Tomcat
Apache httpd Reverse Proxy and Tomcat
 
Compile time dependency injection in Play 2.4 with macwire
Compile time dependency injection in Play 2.4 with macwireCompile time dependency injection in Play 2.4 with macwire
Compile time dependency injection in Play 2.4 with macwire
 

Semelhante a Check Yourself Before You Wreck Yourself: Auditing and Improving the Performance of Boomerang

When third parties stop being polite... and start getting real
When third parties stop being polite... and start getting realWhen third parties stop being polite... and start getting real
When third parties stop being polite... and start getting realCharles Vazac
 
Fluent 2018: When third parties stop being polite... and start getting real
Fluent 2018: When third parties stop being polite... and start getting realFluent 2018: When third parties stop being polite... and start getting real
Fluent 2018: When third parties stop being polite... and start getting realAkamai Developers & Admins
 
When Third Parties Stop Being Polite... and Start Getting Real
When Third Parties Stop Being Polite... and Start Getting RealWhen Third Parties Stop Being Polite... and Start Getting Real
When Third Parties Stop Being Polite... and Start Getting RealNicholas Jansma
 
Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationDavid Amend
 
Measuring Front-End Performance - What, When and How?
Measuring Front-End Performance - What, When and How?Measuring Front-End Performance - What, When and How?
Measuring Front-End Performance - What, When and How?Gareth Hughes
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 
Shining a light on performance (js meetup)
Shining a light on performance (js meetup)Shining a light on performance (js meetup)
Shining a light on performance (js meetup)Yoav Niran
 
implement lighthouse-ci with your web development workflow
implement lighthouse-ci with your web development workflowimplement lighthouse-ci with your web development workflow
implement lighthouse-ci with your web development workflowWordPress
 
Prometheus and Docker (Docker Galway, November 2015)
Prometheus and Docker (Docker Galway, November 2015)Prometheus and Docker (Docker Galway, November 2015)
Prometheus and Docker (Docker Galway, November 2015)Brian Brazil
 
An Introduction to Pagespeed Optimisation
An Introduction to Pagespeed OptimisationAn Introduction to Pagespeed Optimisation
An Introduction to Pagespeed OptimisationPratyush Majumdar
 
Client-Side Performance Testing
Client-Side Performance TestingClient-Side Performance Testing
Client-Side Performance TestingAnand Bagmar
 
Optimising Web Application Frontend
Optimising Web Application FrontendOptimising Web Application Frontend
Optimising Web Application Frontendtkramar
 
Brighton SEO July 2021 How JavaScript is preventing you from passing Core W...
Brighton SEO July 2021   How JavaScript is preventing you from passing Core W...Brighton SEO July 2021   How JavaScript is preventing you from passing Core W...
Brighton SEO July 2021 How JavaScript is preventing you from passing Core W...Izabela Wisniewska
 
Demystifying web performance tooling and metrics
Demystifying web performance tooling and metricsDemystifying web performance tooling and metrics
Demystifying web performance tooling and metricsAnna Migas
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindSam Keen
 
The need for Speed: Advanced #webperf - SEOday 2018
The need for Speed: Advanced #webperf - SEOday 2018The need for Speed: Advanced #webperf - SEOday 2018
The need for Speed: Advanced #webperf - SEOday 2018Bastian Grimm
 
Антон Серпутько “Testing and optimization of client-side performance”
Антон Серпутько “Testing and optimization of client-side performance” Антон Серпутько “Testing and optimization of client-side performance”
Антон Серпутько “Testing and optimization of client-side performance” Dakiry
 

Semelhante a Check Yourself Before You Wreck Yourself: Auditing and Improving the Performance of Boomerang (20)

When third parties stop being polite... and start getting real
When third parties stop being polite... and start getting realWhen third parties stop being polite... and start getting real
When third parties stop being polite... and start getting real
 
Fluent 2018: When third parties stop being polite... and start getting real
Fluent 2018: When third parties stop being polite... and start getting realFluent 2018: When third parties stop being polite... and start getting real
Fluent 2018: When third parties stop being polite... and start getting real
 
When Third Parties Stop Being Polite... and Start Getting Real
When Third Parties Stop Being Polite... and Start Getting RealWhen Third Parties Stop Being Polite... and Start Getting Real
When Third Parties Stop Being Polite... and Start Getting Real
 
Browser Based Performance Testing and Tuning
Browser Based Performance Testing and TuningBrowser Based Performance Testing and Tuning
Browser Based Performance Testing and Tuning
 
Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous Integration
 
Presemtation Tier Optimizations
Presemtation Tier OptimizationsPresemtation Tier Optimizations
Presemtation Tier Optimizations
 
Camunda BPM 7.2 - English
Camunda BPM 7.2 - EnglishCamunda BPM 7.2 - English
Camunda BPM 7.2 - English
 
Measuring Front-End Performance - What, When and How?
Measuring Front-End Performance - What, When and How?Measuring Front-End Performance - What, When and How?
Measuring Front-End Performance - What, When and How?
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 
Shining a light on performance (js meetup)
Shining a light on performance (js meetup)Shining a light on performance (js meetup)
Shining a light on performance (js meetup)
 
implement lighthouse-ci with your web development workflow
implement lighthouse-ci with your web development workflowimplement lighthouse-ci with your web development workflow
implement lighthouse-ci with your web development workflow
 
Prometheus and Docker (Docker Galway, November 2015)
Prometheus and Docker (Docker Galway, November 2015)Prometheus and Docker (Docker Galway, November 2015)
Prometheus and Docker (Docker Galway, November 2015)
 
An Introduction to Pagespeed Optimisation
An Introduction to Pagespeed OptimisationAn Introduction to Pagespeed Optimisation
An Introduction to Pagespeed Optimisation
 
Client-Side Performance Testing
Client-Side Performance TestingClient-Side Performance Testing
Client-Side Performance Testing
 
Optimising Web Application Frontend
Optimising Web Application FrontendOptimising Web Application Frontend
Optimising Web Application Frontend
 
Brighton SEO July 2021 How JavaScript is preventing you from passing Core W...
Brighton SEO July 2021   How JavaScript is preventing you from passing Core W...Brighton SEO July 2021   How JavaScript is preventing you from passing Core W...
Brighton SEO July 2021 How JavaScript is preventing you from passing Core W...
 
Demystifying web performance tooling and metrics
Demystifying web performance tooling and metricsDemystifying web performance tooling and metrics
Demystifying web performance tooling and metrics
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / Webgrind
 
The need for Speed: Advanced #webperf - SEOday 2018
The need for Speed: Advanced #webperf - SEOday 2018The need for Speed: Advanced #webperf - SEOday 2018
The need for Speed: Advanced #webperf - SEOday 2018
 
Антон Серпутько “Testing and optimization of client-side performance”
Антон Серпутько “Testing and optimization of client-side performance” Антон Серпутько “Testing and optimization of client-side performance”
Антон Серпутько “Testing and optimization of client-side performance”
 

Mais de Nicholas Jansma

Reliably Measuring Responsiveness
Reliably Measuring ResponsivenessReliably Measuring Responsiveness
Reliably Measuring ResponsivenessNicholas Jansma
 
Measuring Real User Performance in the Browser
Measuring Real User Performance in the BrowserMeasuring Real User Performance in the Browser
Measuring Real User Performance in the BrowserNicholas Jansma
 
Measuring the Performance of Single Page Applications
Measuring the Performance of Single Page ApplicationsMeasuring the Performance of Single Page Applications
Measuring the Performance of Single Page ApplicationsNicholas Jansma
 
Javascript Module Patterns
Javascript Module PatternsJavascript Module Patterns
Javascript Module PatternsNicholas Jansma
 
Appcelerator Titanium Intro (2014)
Appcelerator Titanium Intro (2014)Appcelerator Titanium Intro (2014)
Appcelerator Titanium Intro (2014)Nicholas Jansma
 
The Happy Path: Migration Strategies for Node.js
The Happy Path: Migration Strategies for Node.jsThe Happy Path: Migration Strategies for Node.js
The Happy Path: Migration Strategies for Node.jsNicholas Jansma
 
Using Phing for Fun and Profit
Using Phing for Fun and ProfitUsing Phing for Fun and Profit
Using Phing for Fun and ProfitNicholas Jansma
 
Using Modern Browser APIs to Improve the Performance of Your Web Applications
Using Modern Browser APIs to Improve the Performance of Your Web ApplicationsUsing Modern Browser APIs to Improve the Performance of Your Web Applications
Using Modern Browser APIs to Improve the Performance of Your Web ApplicationsNicholas Jansma
 
Appcelerator Titanium Intro
Appcelerator Titanium IntroAppcelerator Titanium Intro
Appcelerator Titanium IntroNicholas Jansma
 
Debugging IE Performance Issues with xperf, ETW and NavigationTiming
Debugging IE Performance Issues with xperf, ETW and NavigationTimingDebugging IE Performance Issues with xperf, ETW and NavigationTiming
Debugging IE Performance Issues with xperf, ETW and NavigationTimingNicholas Jansma
 

Mais de Nicholas Jansma (13)

Modern Metrics (2022)
Modern Metrics (2022)Modern Metrics (2022)
Modern Metrics (2022)
 
Reliably Measuring Responsiveness
Reliably Measuring ResponsivenessReliably Measuring Responsiveness
Reliably Measuring Responsiveness
 
Measuring Real User Performance in the Browser
Measuring Real User Performance in the BrowserMeasuring Real User Performance in the Browser
Measuring Real User Performance in the Browser
 
Measuring Continuity
Measuring ContinuityMeasuring Continuity
Measuring Continuity
 
Measuring the Performance of Single Page Applications
Measuring the Performance of Single Page ApplicationsMeasuring the Performance of Single Page Applications
Measuring the Performance of Single Page Applications
 
Javascript Module Patterns
Javascript Module PatternsJavascript Module Patterns
Javascript Module Patterns
 
Sails.js Intro
Sails.js IntroSails.js Intro
Sails.js Intro
 
Appcelerator Titanium Intro (2014)
Appcelerator Titanium Intro (2014)Appcelerator Titanium Intro (2014)
Appcelerator Titanium Intro (2014)
 
The Happy Path: Migration Strategies for Node.js
The Happy Path: Migration Strategies for Node.jsThe Happy Path: Migration Strategies for Node.js
The Happy Path: Migration Strategies for Node.js
 
Using Phing for Fun and Profit
Using Phing for Fun and ProfitUsing Phing for Fun and Profit
Using Phing for Fun and Profit
 
Using Modern Browser APIs to Improve the Performance of Your Web Applications
Using Modern Browser APIs to Improve the Performance of Your Web ApplicationsUsing Modern Browser APIs to Improve the Performance of Your Web Applications
Using Modern Browser APIs to Improve the Performance of Your Web Applications
 
Appcelerator Titanium Intro
Appcelerator Titanium IntroAppcelerator Titanium Intro
Appcelerator Titanium Intro
 
Debugging IE Performance Issues with xperf, ETW and NavigationTiming
Debugging IE Performance Issues with xperf, ETW and NavigationTimingDebugging IE Performance Issues with xperf, ETW and NavigationTiming
Debugging IE Performance Issues with xperf, ETW and NavigationTiming
 

Último

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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Último (20)

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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Check Yourself Before You Wreck Yourself: Auditing and Improving the Performance of Boomerang

  • 1. Check Yourself Before You Wreck Yourself Auditing and Improving the Performance of Boomerang Nic Jansma njansma@akamai.com @nicj
  • 2. Why are we here today? ● Boomerang: an open-source Real User Monitoring (RUM) third-party library ○ https://github.com/akamai/boomerang ● Why performance matters to us ● Performance Audit ● Improvements! ● Testing, Validation, Protecting against Regressions
  • 3. Why should you care? ● Do you develop a library that other teams, companies or projects use? ● Do you use a third-party library? ○ Any library that you didn't write ○ They might be packaged in your application’s JavaScript bundle, included via a cross- origin <script> tag, or injected via a tag manager. Boss: Developer, please add this fancy new script! <script async src="//cdn.remarketing.com/js/foo.min.js"></script> What could go wrong? It’s just one simple line!
  • 4. <script async src="//cdn.remarketing.com/js/foo.min.js"></script> That one little line can: ● Cause your page to stop loading ● Slow down other components ● Create incompatibilities with other libraries ● Change from underneath you ● Take total control of your site What can go wrong?
  • 5. Boomerang ● 14,000+ mPulse sites ○ > 1 billion page loads a day ● 76,000 - 460,000 sites using open-source boomerang.js (estimate) https://discuss.httparchive.org/t/who-are-the-top-rum-analytics-providers/ https://trends.builtwith.com/javascript/Boomerang
  • 6. “Everything should have a value, because everything has a cost” - @tkadlec How can we judge the cost of a script? $ ls -al modernizr.js* -rw-r--r--@ 1 nicjansma staff 92,475 May 30 20:20 modernizr.js -rw-r--r-- 1 nicjansma staff 32,599 May 30 20:21 modernizr.js.gz … it’s... cheap??? Evaluating the Cost of a 3rd Party
  • 7. A third-party’s size (bytes) contributes to the overall Page Weight. Page Weight is important - it has an effect on how long the page takes to load, especially on lower-end devices or slower connections. Lowering the Page Weight can improve load times, so you want to factor the byte cost of a third-party into your overall Performance Budget. … but while it’s the easiest way to judge a third party, it’s just one aspect of the overall cost. Resource Weight
  • 8. A 3rd-Party Script’s Lifecycle & Costs 1. Loader Snippet / <script> 2. Download 3. Parse + Compile 4. Initialize 5. Runtime / event handlers
  • 10. Boomerang Performance Audit 1. Loader Snippet / <script> 2. Download 3. Parse + Compile 4. Initialize 5. Runtime / event handlers
  • 11. A 3rd-Party Script’s Lifecycle Critical path! 1. Script tag itself has no cost: <script src="..."></script> 2. Snippets have a cost (2-10ms on desktop Chrome): <script type="text/javascript"> (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://.../foo.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })(); </script> 1. Loader Snippet / <script> 2. Download 3. Parse + Compile 4. Initialize 5. Runtime / event handlers
  • 12. Boomerang's Loader Snippet 3. Boomerang's Loader Snippet Completely async and non-blocking Better than <script async> Cost: 2-40ms More expensive than <script>, but guaranteed to not block https://akamai.github.io/boomerang/tutorial-loader-snippet.html 1. Loader Snippet / <script> 2. Download 3. Parse + Compile 4. Initialize 5. Runtime / event handlers
  • 13. A 3rd-Party Script’s Lifecycle Every byte affects overall page weight. Critical path? ● External <script> / tag: no (unless sharing domain) ● Bundled with other components: yes? Load from a CDN! The script may load additional resources. 1. Loader Snippet / <script> 2. Download 3. Parse + Compile 4. Initialize 5. Runtime / event handlers
  • 14. A 3rd-Party Script’s Lifecycle //requestmap.webperf.tools 1. Loader Snippet / <script> 2. Download 3. Parse + Compile 4. Initialize 5. Runtime / event handlers
  • 15. A 3rd-Party Script’s Lifecycle ● underscore.js 7 KB ● Google Analytics 14 KB ● moment 16 KB ● jQuery 29 KB ● React 32 KB ● Twitter 34 KB ● Boomerang 47 KB ● Angular 59 KB ● D3 71 KB 1. Loader Snippet / <script> 2. Download 3. Parse + Compile 4. Initialize 5. Runtime / event handlers
  • 16. Boomerang is built with a plug-in architecture and you can build smaller builds if you'd prefer. For example, if you don't need: SPA, XHR, UserTiming or Error Tracking support Boomerang shrinks from 47 KB to 26 KB. A 3rd-Party Script’s Lifecycle 1. Loader Snippet / <script> 2. Download 3. Parse + Compile 4. Initialize 5. Runtime / event handlers
  • 17. A 3rd-Party Script’s Lifecycle Critical path! After being fetched, the browser must parse / compile the (decompressed) JavaScript before it’s executed. Less bytes = less parse / compile. ● Moment 5 ms 143 KB ● Boomerang 10 ms 188 KB ● Twitter Widget 10 ms 227 KB ● jQuery 11 ms 265 1. Loader Snippet / <script> 2. Download 3. Parse + Compile 4. Initialize 5. Runtime / event handlers
  • 18. A 3rd-Party Script’s Lifecycle Critical path! Many scripts will initialize (do some work) at startup - create structures, globals, hook events, etc. ● moment 2 ms ● jQuery 9 ms ● Boomerang 10 ms ● Angular 12 ms ● Twitter Widget 20 ms 1. Loader Snippet / <script> 2. Download 3. Parse + Compile 4. Initialize 5. Runtime / event handlers
  • 19. Critical path! The library should be there for a reason. This reason will do work periodically or based on user interactions. ● SPA framework updating the view after a route change ● Analytics scripts sending beacons ● Charting library responding to user interactions A 3rd-Party Script’s Lifecycle 1. Loader Snippet / <script> 2. Download 3. Parse + Compile 4. Initialize 5. Runtime / event handlers
  • 20. Boomerang: depending on the site, 10-40ms at onload Upwards of 300ms on resource-heavy sites on low-end devices A 3rd-Party Script’s Lifecycle 1. Loader Snippet / <script> 2. Download 3. Parse + Compile 4. Initialize 5. Runtime / event handlers
  • 21. Critical path! All bold could be done on the main thread (depending on the browser) and can can cause Long Tasks. A 3rd-Party Script’s Lifecycle 1. Loader Snippet / <script> 2. Download 3. Parse + Compile 4. Initialize 5. Runtime / event handlers
  • 22. A task is work the browser is doing to build the page, such as parsing HTML, executing JavaScript, or performing layout. This happens on the main thread. The browser cannot respond to user input (clicking, scrolling, etc) while executing a task. Long Tasks are due to complex work that requires more than 50ms of execution time. i.e. parsing or executing complex JavaScript. Long Tasks will delay Time to Interactive - the point at which your app is responsive. Long Tasks and Time to Interactive
  • 23. Boomerang’s Performance Audit https://nicj.net/an-audit-of-boomerangs-performance/ TL;DR boomerang’s 2018 cost (high-end to low-end devices): 1. Loader Snippet 2 - 40 ms 2. Download 188 KB raw / 47 KB gzip (non-blocking) 3. Parse 6 - 47 ms 4. Initialize 3 - 15 ms 5. @onload 10 - 300 ms 6. Beacon 2 - 20 KB 7. Runtime minimal Tracking improvements @ https://github.com/akamai/boomerang/issues
  • 24. Performance Audit Tools Developer tools are your friend! Profilers can point to opportunities My advice: ● Take your time ● Get a sense for the overall picture ● Look for extremes - longest duration, tallest stack
  • 25. Chrome Lighthouse developers.google.com /web/tools/lighthouse/ Evaluating for Performance RequestMap requestmap.webperf.tools WebPagetest webpagetest.org 3rdParty.io 3rdparty.io
  • 26. Boomerang’s Performance Audit https://nicj.net/an-audit-of-boomerangs-performance/ We found room for improvement! Filed 15 issues. Examples: ● ResourceTiming Compression is expensive ● Loader Snippet Performance in Edge ● Breakup plugin creation / initialization to avoid long tasks ● Beacon: Review cookie access ● Beacon: Memory: Node counting is expensive ● Unload beacon size ● Unload Beacon: Memory plugin updating DOM counts Tracking improvements @ https://github.com/akamai/boomerang/issues
  • 27. https://nicj.net/boomerang-performance-update/ ● New Loader Snippet ● ResourceTiming Optimization ● Removed Debug Messages ● Improved Minification ● Reduced Cookie Size ● Reduced Cookie Access ● Simplified MD5 plugin ● Simplified SPA plugin ● Enabled Brotli for CDN Boomerang’s Performance Improvements Using <link rel="preload"> we can load async and non-blocking without an IFRAME Reduced 2-40ms to 1ms for browsers that support Preload!
  • 28. https://nicj.net/boomerang-performance-update/ ● New Loader Snippet ● ResourceTiming Optimization ● Removed Debug Messages ● Improved Minification ● Enabled Brotli for CDN ● Reduced Cookie Size ● Reduced Cookie Access ● Simplified MD5 plugin ● Simplified SPA plugin Boomerang’s Performance Improvements Compressing ResourceTiming data was our most expensive task Tweaked the algorithm slightly to be slightly- less-than-perfect for a 4x speedup Reduced some sites' cost from 100ms to 25ms or 300ms to 75ms
  • 29. https://nicj.net/boomerang-performance-update/ ● New Loader Snippet ● ResourceTiming Optimization ● Removed Debug Messages ● Improved Minification ● Enabled Brotli for CDN ● Reduced Cookie Size ● Reduced Cookie Access ● Simplified MD5 plugin ● Simplified SPA plugin We were shipping debug log messages even though the debug log was disabled (6% saving) Changed from Uglify2 to Uglify3 (1.3% saving) Enabled Brotli on the Akamai CDN (11.2% saving) SPA and MD5 plugins refactored (2.8% saving) Boomerang’s Performance Improvements
  • 30. https://nicj.net/boomerang-performance-update/ ● New Loader Snippet ● ResourceTiming Optimization ● Removed Debug Messages ● Improved Minification ● Enabled Brotli for CDN ● Reduced Cookie Size ● Reduced Cookie Access ● Simplified MD5 plugin ● Simplified SPA plugin Boomerang’s Performance Improvements We set a cookie to track sessions Changed how we stored some of the data (e.g. hash instead of a full URL, Base36 instead of Base10 for numbers): 41% smaller We were reading/writing constantly during startup -- simplified our operations from 21 reads and 8 writes down to 2 reads and 4 writes
  • 31. https://nicj.net/boomerang-performance-update/ ● New Loader Snippet ● ResourceTiming Optimization ● Removed Debug Messages ● Improved Minification ● Enabled Brotli for CDN ● Reduced Cookie Size ● Reduced Cookie Access ● Simplified MD5 plugin ● Simplified SPA plugin Boomerang’s Performance Improvements We were using MD5 for hashing and comparing URLs quickly This plugin took 8.1 KB and could hash 35,397 URLs/sec We replaced with the FNV algorithm: 0.34 KB and 113,532 URLs/sec SPA plugin was simplified and removed framework-specific support in favor of just monitoring the window.History object
  • 32. Boomerang’s Performance Audit https://nicj.net/boomerang-performance-update/ After fixes: 1. Loader Snippet 2 - 40 ms 1-20 ms (1 ms in modern browsers) 2. Download 188 KB raw / 47 KB gzip 196 KB raw / 47 KB brotli 3. Parse 6 - 47 ms (same) 4. Initialize 3 - 15 ms (same) 5. @onload 10 - 300 ms 5-75 ms 6. Beacon 2 - 20 KB (same) 7. Runtime minimal Tracking improvements @ https://github.com/akamai/boomerang/issues
  • 33. Boomerang’s Performance Audit https://nicj.net/boomerang-performance-update/ Opportunities! 1. Loader Snippet 2 - 40 ms 1-20 ms (1 ms in modern browsers) 2. Download 188 KB raw / 47 KB gzip 196 KB raw / 47 KB brotli 3. Parse 6 - 47 ms (same) 4. Initialize 3 - 15 ms (same) 5. @onload 10 - 300 ms 5-75 ms 6. Beacon 2 - 20 KB (same) 7. Runtime minimal Tracking improvements @ https://github.com/akamai/boomerang/issues
  • 34. Continuous, Gradual Improvement In a mature product with a healthy process you're much more likely to see a 50% gain come in the form of many 5% gains compounding to get to your goal via sustained effort and quality control https://docs.microsoft.com/en-us/archive/blogs/ricom/the-performance-war-win-it-5-at-a-time
  • 35. Protecting Against Regressions Boomerang Performance Lab / Test Suite Simple set of scenarios & metrics we capture each build Tracks: ● CPU time via headless Profiler ● Counts & Durations via UserTiming marks & measures ● Sizes of code & plugins https://akamai.github.io/boomerang/tutorial-perf-tests.html
  • 36. You can capture your script's own runtime stats, Long Tasks and JavaScript errors JavaScript Self Profiling API Realtime Telemetry
  • 37. Boss: Developer, please add this fancy new script! <script async src="//cdn.remarketing.com/js/foo.min.js"></script> ● Perform a light-weight audit ● Do its benefits outweigh its costs? ● Ask if the library has published performance information ● Every third-party should have an owner or “internal champion” What can you do?
  • 38. What 3rd Party Scripts Should be Doing... They should: ● Use a CDN ● Compress resources ● Set caching headers ● Set Timing-Allow-Origin ● Set ACAO ● Support HTTPS ● Support HTTP/2 ● Minify ● Have ~100% uptime Minimal: ● JavaScript size ● Work without yielding ● Network latency ● CPU ● Requests ● Cookies ● DOM changes / additions ● Event hooks ● Global variables ● Patching ● Changes without your permission No: ● document.write() ● alert() or prompt() ● eval() ● debugger; ● Console messages ● JavaScript errors ● Including other libs ● Redirects ● Known vulnerabilities
  • 40. ● https://nicj.net/an-audit-of-boomerangs-performance/ ● https://nicj.net/boomerang-performance-update/ ● https://github.com/akamai/boomerang/issues ● https://3rdparty.io/ Links