3rd Party Footprint @ Webrebels

102
#webrebels 3rd Party Footprint EVALUATING THE PERFORMANCE OF EXTERNAL SCRIPTS BARBARA BERMES /bbinto

Transcript of 3rd Party Footprint @ Webrebels

Page 1: 3rd Party Footprint @ Webrebels

#webrebels

3rd Party FootprintEVALUATING THE PERFORMANCE OF EXTERNAL SCRIPTS

BARBARA BERMES /bbinto

Page 2: 3rd Party Footprint @ Webrebels

#webrebels

3rd Party FootprintEVALUATING THE PERFORMANCE OF EXTERNAL SCRIPTS

BARBARA BERMES /bbinto

Page 3: 3rd Party Footprint @ Webrebels

#webrebels

I live in Toronto, Canada

Page 4: 3rd Party Footprint @ Webrebels

#webrebels

I love burritos

Page 5: 3rd Party Footprint @ Webrebels

#webrebels

I’m passionate about web perf

Page 6: 3rd Party Footprint @ Webrebels

#webrebelsLet’s get this 3rd party started!

Page 7: 3rd Party Footprint @ Webrebels

#LDNWebPerf#webrebels

In the strictest sense, anything served to the client that’s provided by an

organization that’s not the website provider is considered to be third-party

“”–Ben Vinegar, Author of “Third-Party Script”

What is a 3rd party script?

Page 8: 3rd Party Footprint @ Webrebels

#LDNWebPerf#webrebels

Types of 3rd party scriptsAdvertising Tracking and Analytics Fonts Social Media Libraries and Frameworks

Page 9: 3rd Party Footprint @ Webrebels

#webrebels

What’s the #1 used 3rd Party script?

Page 10: 3rd Party Footprint @ Webrebels

#LDNWebPerf#webrebels

Stats from Big Query

Page 11: 3rd Party Footprint @ Webrebels

#webrebels

AKAMAI (FB)14%

TWITTER 5%

FACEBOOK 10%

GOOGLE 71%

Top 10

Page 12: 3rd Party Footprint @ Webrebels

#webrebels

Visualize the impact of 3rd party scripts

Page 13: 3rd Party Footprint @ Webrebels

#webrebels

Page 14: 3rd Party Footprint @ Webrebels

#webrebels

Page 15: 3rd Party Footprint @ Webrebels

#webrebels

Page 16: 3rd Party Footprint @ Webrebels

#webrebels

Page 17: 3rd Party Footprint @ Webrebels

#webrebels

Foreign content overload

Page 18: 3rd Party Footprint @ Webrebels

#LDNWebPerf#webrebels

Example: Wired• Body Level One

• Body Level Two

• Body Level Three

• Body Level Four

• Body Level Five

Page 19: 3rd Party Footprint @ Webrebels

#webrebels

But what’s the issue?

Page 20: 3rd Party Footprint @ Webrebels

#LDNWebPerf#webrebels

The Issues and Negative Impacts

PerformanceFront-end Single Point of Failure (SPOF) Privacy

Page 21: 3rd Party Footprint @ Webrebels

#LDNWebPerf#webrebels

Potential SolutionsSafe SnippetsCaching and Hosted LibrariesTools and Initiatives

Page 22: 3rd Party Footprint @ Webrebels

#webrebels

Performance

Page 23: 3rd Party Footprint @ Webrebels

#webrebels

- John HjelmstadGoogle I/O 2012 (How we Make JavaScript Widgets Scream)

The value you get out of the widget needs to be greater than the performance hit you are taking

Rule of Thumb

Page 24: 3rd Party Footprint @ Webrebels

#webrebels

A user who has to endure an 8-second download delay spends only 1% of their total viewing time looking at the featured promotional space on a landing page.

In contrast, a user who receives instantaneous page rendering spends 20% of viewing time within the promotional area (source: Jakob Nielsen)

Perception of promotional space

Page 25: 3rd Party Footprint @ Webrebels

#webrebels

A website without ads?

Page 26: 3rd Party Footprint @ Webrebels

#LDNWebPerf#webrebels

The performance impact of ads

• Body Level One

• Body Level Two

• Body Level Three

• Body Level Four

• Body Level Five

Page 27: 3rd Party Footprint @ Webrebels

#webrebels

40%Using no (client-side) ad code reduced CBC’s page load time by 40%

<script/>

Page 28: 3rd Party Footprint @ Webrebels

#webrebels

Monitor foreign content, constantly!

Page 29: 3rd Party Footprint @ Webrebels

#LDNWebPerf#webrebels

Arith

met

ic M

ean

in s

0

2.5

5

7.5

10

10/4/12 10/31/12

Bad 3rd parties (CBC mobile Site)

Smooth sailing

Client-side Ads

Ads turned offServer-side Ads

Source: Keynote Daily Reports

We noticed a spike

Page 30: 3rd Party Footprint @ Webrebels

#webrebels

Single point of failure

Page 31: 3rd Party Footprint @ Webrebels

#LDNWebPerf#webrebels

A single point of failure (SPOF) is a part of a system that, if it fails, will stop the entire system from working

–Wikipedia

SPOF

Page 32: 3rd Party Footprint @ Webrebels

#LDNWebPerf#webrebels

The Offender

It will block rendering anything after this line

Page 33: 3rd Party Footprint @ Webrebels

#webrebels

Yeah…whatever3rd providers don’t really go down…

Page 34: 3rd Party Footprint @ Webrebels

#webrebels

Oh yes, they do!

Page 35: 3rd Party Footprint @ Webrebels

#webrebels

Page 36: 3rd Party Footprint @ Webrebels

#webrebels

Page 37: 3rd Party Footprint @ Webrebels

#webrebels

Page 38: 3rd Party Footprint @ Webrebels

#webrebels

Page 39: 3rd Party Footprint @ Webrebels

#webrebels

Page 40: 3rd Party Footprint @ Webrebels

#webrebels

Page 41: 3rd Party Footprint @ Webrebels

#webrebels

Page 42: 3rd Party Footprint @ Webrebels

#webrebels

Title TextTitle Text

Page 43: 3rd Party Footprint @ Webrebels

#webrebels

Page 44: 3rd Party Footprint @ Webrebels

#webrebels

The Great Firewall of China

Page 45: 3rd Party Footprint @ Webrebels

#webrebels

Simulating SPOF on TechCrunch

Page 46: 3rd Party Footprint @ Webrebels

#webrebels

Page 47: 3rd Party Footprint @ Webrebels

#velocityconf

SPOF-O-Matic

Page 48: 3rd Party Footprint @ Webrebels

#webrebels

Page 49: 3rd Party Footprint @ Webrebels

#webrebels

SPOF WIRED

Without SPOFWith SPOF: Visually complete 40s

Page 50: 3rd Party Footprint @ Webrebels

#webrebels

Let’s crash this party

Page 51: 3rd Party Footprint @ Webrebels

#webrebels

Title TextTitle Text

#webrebels

Page 52: 3rd Party Footprint @ Webrebels

#webrebels

Page 53: 3rd Party Footprint @ Webrebels

#velocityconf#webrebels

Page 54: 3rd Party Footprint @ Webrebels

#velocityconf#webrebels

Page 55: 3rd Party Footprint @ Webrebels

#webrebels

Initializing client-side scripts

Page 56: 3rd Party Footprint @ Webrebels

#webrebels

Safest (previous) way: Dynamic script tag

(to cover most of the browsers)

Page 57: 3rd Party Footprint @ Webrebels

#webrebelshttp://www.phpied.com/social-button-bffs/

Asynchronous Loading

Page 58: 3rd Party Footprint @ Webrebels

#webrebels

Title Text

Asynchronous Loading

Page 59: 3rd Party Footprint @ Webrebels

#webrebels

Title Text

Asynchronous Loading

Page 60: 3rd Party Footprint @ Webrebels

#webrebels

Title Text

Asynchronous Loading

Page 61: 3rd Party Footprint @ Webrebels

#webrebels

Title Text

Asynchronous Loading

Page 62: 3rd Party Footprint @ Webrebels

#webrebels

Title Text

Asynchronous Loading

Page 63: 3rd Party Footprint @ Webrebels

#webrebels

Title Text

Asynchronous Loading

Page 64: 3rd Party Footprint @ Webrebels

#webrebels

Before

Page 65: 3rd Party Footprint @ Webrebels

#webrebels

5 seconds 25 seconds

#webrebels

Page 66: 3rd Party Footprint @ Webrebels

#webrebels

After

Page 67: 3rd Party Footprint @ Webrebels

#webrebels

AFTER5 seconds

#webrebels

Page 68: 3rd Party Footprint @ Webrebels

#webrebels

Page 69: 3rd Party Footprint @ Webrebels

#webrebels

The Future

Page 70: 3rd Party Footprint @ Webrebels

#LDNWebPerf#webrebels

Async or Defer JS

Page 71: 3rd Party Footprint @ Webrebels

#LDNWebPerf#webrebels

Async or Defer JS

Page 72: 3rd Party Footprint @ Webrebels

#LDNWebPerf#webrebels

Async and Defer JS

Page 73: 3rd Party Footprint @ Webrebels

#LDNWebPerf#webrebels

Protect yourself with the help of tools

Ad-hoc browser toolsContinuous integration and deployment tools

Page 74: 3rd Party Footprint @ Webrebels

#webrebels

Caching?Don’t always rely on it!

Page 75: 3rd Party Footprint @ Webrebels

#LDNWebPerf#webrebels

30min

3 min

Cache Policies

20 min

30 min

1 hr

20 min

Page 76: 3rd Party Footprint @ Webrebels

#webrebels

What about hosted libraries?

Page 77: 3rd Party Footprint @ Webrebels

#LDNWebPerf#webrebels

Pages using Google CDN(Top Alexa Websites)

0%

0.25%

0.5%

Jan '11 Jan '13 Jan '13 Jan '14 Jan '15

11%

17%

26%

37%

47%

Perc

enta

geGoogle Hosted Libraries

PAGES USING GOOGLE LIBRARIES API

52% 48%

Page 78: 3rd Party Footprint @ Webrebels

#LDNWebPerf#webrebels

Anywhere?

Don’t just copy and paste

Page 79: 3rd Party Footprint @ Webrebels

#webrebels

SPOF Alert!

Page 80: 3rd Party Footprint @ Webrebels

#webrebels

Don’t do this….

Page 81: 3rd Party Footprint @ Webrebels

#webrebels

Rather do this: Silent Fail

Page 82: 3rd Party Footprint @ Webrebels

#webrebelsSource: May 2015, Big Query result on jQuery from Google CDNs

Google’s hostest jQuery fragmentation

OTHER 30%

1.4.2 5%1.11.0

6%1.8.2 6%

1.11.1 7%

1.9.1 8%

1.8.3 8%

1.10.2 8%

1.7.1 10%

1.7.2 12%

Page 83: 3rd Party Footprint @ Webrebels

#webrebels

So, whats the verdict:Hosted Libraries or not?

Page 84: 3rd Party Footprint @ Webrebels

#webrebels

Privacy

Page 85: 3rd Party Footprint @ Webrebels

#webrebels

Title Texthttps://developers.facebook.com/docs/plugins/like-button/

Page 86: 3rd Party Footprint @ Webrebels

#webrebels

Title TextWhat they don’t really tell you that they maybe….track the visited website, your IP, and more….????Did you agree to that?

Page 87: 3rd Party Footprint @ Webrebels

#webrebels

Open Source Initiatives and Resources

Page 88: 3rd Party Footprint @ Webrebels

#webrebels

Privacy Hero heise’s Opt-in Solution

Page 89: 3rd Party Footprint @ Webrebels

#webrebels

Page 90: 3rd Party Footprint @ Webrebels

#webrebels

Page 91: 3rd Party Footprint @ Webrebels

#velocityconf

Page 92: 3rd Party Footprint @ Webrebels

#LDNWebPerf#webrebels

Measuring 3rd party content on your site

Navigation Timing APIResource Timing API

Page 93: 3rd Party Footprint @ Webrebels

#webrebels

0

120

240

Jan '14 Feb '14 Mar '14 Apr '14 May '14 Jun '14 Jul '14 May '15

82 86 8699

130

157168

232

Fastly Optimizely

Instagram Cedexis Twitter TypeKit

CDNPlanet Walmart Tumblr Disqus

Adoption of Timing-Allow-Origin Header (Top Alexa Websites)

Page 94: 3rd Party Footprint @ Webrebels

#webrebels

Title Textjsmanners

Page 95: 3rd Party Footprint @ Webrebels

#webrebels

Page 96: 3rd Party Footprint @ Webrebels

#webrebels

Title Texthttps://github.com/triblondon/

Contribute on Github!

Page 97: 3rd Party Footprint @ Webrebels

#webrebels

Next time before you copy and paste

Page 98: 3rd Party Footprint @ Webrebels

#LDNWebPerf#webrebels

• Refuse 3rd party content that doesn’t provide async options or is not minified

• Put the risk in the SLA (uptime etc.)

• Review jsmanners

• Educate other (junior) developers

• Test it via navigation and resource timing where applicable

What to do as a Publisher & Developer

Page 99: 3rd Party Footprint @ Webrebels

#LDNWebPerf#webrebels

• Ask for server-side options

• Evaluate tag managers

• Investigate hosted libraries (if no own CDN is available)

• Monitor, monitor, ….and monitor

• Evaluate the need of the script with marketing and sales

What to do as a Publisher & Developer

Page 100: 3rd Party Footprint @ Webrebels

#LDNWebPerf#webrebels

What to do as a Script Provider

• Provide non-blocking code samples and snippets

• Educate developers, and verify the integration of your script (proof-check)

Page 101: 3rd Party Footprint @ Webrebels

#webrebels

The Party’s OverThank you

Page 102: 3rd Party Footprint @ Webrebels

#webrebels

Questions?bit.ly/webrebels

Shameless Plug: I wrote a book “Lean Websites” (SitePoint)

Release: end of May 2015