third party footprint: evaluating the performance of external scripts

102
Third Party Footprint Barbara Bermes

Upload: barbara-bermes

Post on 18-Nov-2014

384 views

Category:

Technology


3 download

DESCRIPTION

Copy, paste, but don’t block the rendering! It’s almost impossible to find a website that doesn’t utilize any kind of embedded widgets such as ads, social plugins, or analytics: All of these add-ons are considered 3rd party scripts and promise to increase and benefit publisher’s revenue. Publishers don’t have much control over the provider’s code and inevitably just have to trust their integrity, content security policy, code quality, and performance. Imagine a high-traffic website hosting a twitter widget: Are publishers aware that a sudden twitter server outage could potentially bring down their site if the widget is not properly included? The performance and availability of 3rd party scripts don’t have to become a threat or a nightmare for publishers. Barbara’s talk will not only outline best practices, tools, and tricks on how to sandbox 3rd party scripts, but also help the audience understand bottlenecks, determine potential risks, and elaborate on how to measure their performance. Following this session, managers and developers will be equipped to ask the right questions when choosing 3rd party providers, while developers will be armed with guidelines on how to integrate 3rd party snippets efficiently into their deployment process without slowing down or even bringing down their site.

TRANSCRIPT

Page 1: Third Party Footprint: Evaluating the Performance of External Scripts

Third Party FootprintBarbara Bermes

Page 2: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

3RD PARTY FOOTPRINT

BARBARA BERMES | @BBINTO

EVALUATING THE PERFORMANCE OF EXTERNAL SCRIPTS

Page 3: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

I LIVE IN TORONTO, CANADA

Page 4: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

I LOVE BURRITOS

#VELOCITYBURRITO

Page 5: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

I’M PASSIONATE ABOUT WEB PERF

Page 6: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

LET’S GET THIS PARTY STARTED

Page 7: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

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

“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”

Page 8: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

TYPES OF 3RD PARTY SCRIPTSAdvertising Tracking and Analytics Fonts Social Media Libraries and Frameworks

Page 9: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

WHAT’S THE #1 USED 3RD PARTY SCRIPT?

Page 10: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

STATS FROM BIG QUERY

#velocityconf

Page 11: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

STATS FROM BIG QUERY

#velocityconf

16%

22%62%

Google Facebook Twitter

Page 12: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

31%

34.5

%38

%

2011 2013 2014

32%

36%

38%

DISTRIBUTION OF 3RD PARTY SCRIPTS VS. 1ST PARTY

#velocityconf

Source: http://bigqueri.es/t/what-is-the-distribution-of-1st-party-vs-3rd-party-resources/100

Perc

enta

ge

Page 13: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

VISUALIZE THE IMPACT OF 3RD PARTY SCRIPTS

Page 14: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

Page 15: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

Page 16: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

Page 17: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

FOREIGN CONTENT OVERLOAD!

Page 18: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

EXAMPLE: WIRED

#velocityconf

Page 19: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

BUT WHAT’S THE ISSUE?

Page 20: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

THE ISSUES AND NEGATIVE IMPACTS

PerformanceFront-end Single Point of Failure (SPOF) Privacy

Page 21: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

POTENTIAL SOLUTIONS

Safe Snippets Caching and Hosted Libraries Tools and Initiatives

Page 22: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

PERFORMANCE

Page 23: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

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

RULE OF THUMB

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

Page 24: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

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: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

A WEBSITE WITHOUT ADS???

Page 26: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

THE PERFORMANCE IMPACT OF ADS

#velocityconf

Page 27: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

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

40%

<script/>

Page 28: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

MONITOR FOREIGN CONTENT. CONSTANTLY!

Page 29: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

Arit

hmet

ic M

ean

in s

0

2.5

5

7.5

10

10/4/12 10/31/12

BAD 3RD PARTIES (CBC TOUCH SITE)

Smooth sailing

Client-side Ads

Ads turned offServer-side Ads

Source: Keynote Daily Reports

We noticed a spike

#velocityconf

Page 30: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

SINGLE POINT OF FAILURE

Page 31: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

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

–Wikipedia

Page 32: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

THE OFFENDER

It will block rendering anything after this line

Page 33: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

YEAH….WHATEVER

3RD PROVIDERS DON’T REALLY GO DOWN…

Page 34: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

OH YES. THEY DO!

Page 35: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf#velocityconf

Page 36: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf#velocityconf

Page 37: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf#velocityconf

Page 38: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf#velocityconf

Page 39: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf#velocityconf

Page 40: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf#velocityconf

Page 41: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf#velocityconf

Page 42: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf#velocityconf

Page 43: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

THE GREAT FIREWALL OF CHINA

Page 44: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

SIMULATING SPOF ON TECHCRUNCH

Page 45: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

Page 46: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

SPOF-O-Matic

#velocityconf

Page 47: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf#velocityconf

Page 48: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

SPOF WIRED

Without SPOFWith SPOF: Visually complete 40s

Page 49: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

LET’S CRASH THE PARTY

Page 50: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf#velocityconf

Page 51: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

Page 52: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf#velocityconf

Page 53: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf#velocityconf

Page 54: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

INITIALIZING CLIENT-SIDE SCRIPTS

Page 55: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

SAFEST (PREVIOUS) WAY: DYNAMIC SCRIPT TAG

(to cover most of the browsers)

Page 56: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

ASYNCHRONOUS LOADING

http://www.phpied.com/social-button-bffs/

Page 57: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

ASYNCHRONOUS LOADING

Page 58: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

ASYNCHRONOUS LOADING

Page 59: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

ASYNCHRONOUS LOADING

Page 60: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

ASYNCHRONOUS LOADING

Page 61: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

ASYNCHRONOUS LOADING

Page 62: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

ASYNCHRONOUS LOADING

Page 63: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

BEFORE

Page 64: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

5 seconds 25 seconds

Page 65: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

AFTER

Page 66: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

AFTER5 seconds

Page 67: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

Page 68: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

THE FUTURE

Page 69: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

ASYNC OR DEFER JS

Page 70: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

ASYNC OR DEFER JS

Page 71: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

ASYNC AND DEFER JS

//suggested by W3C

Page 72: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

PROTECT YOURSELF WITH THE HELP OF TOOLS

Ad-hoc browser tools Continuous integration & deployment tools

Page 73: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

CACHING?Don’t always rely on it!

Page 74: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

CACHE POLICIES

30min.

30 min

12 hrs

20 min

1 hr

336 hrs

no cache

1 hr

3 min

#velocityconf

Page 75: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

WHAT ABOUT HOSTED LIBRARIES?

Page 76: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

GOOGLE HOSTED LIBRARIES

#velocityconf

Pages using Google CDN(Top Alexa Websites)

0%

0.2%

0.4%

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

11%

17%

26%

37%

Perc

enta

ge

Page 77: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

DON’T JUST COPY AND PASTE

#velocityconf

Anywhere?

Page 78: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

SPOF ALERT

Page 79: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

DON’T DO THIS….

Page 80: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

RATHER DO THIS: SILENTLY FAIL

Page 81: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

GOOGLE’S HOSTED JQUERY FRAGMENTATION

Source: Aug 2014, Big Query result on jQuery from Google CDNs #velocityconf

Page 82: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

SO, WHATS THE VERDICT: HOSTED LIBRARIES OR NOT?

Page 83: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

PRIVACY

Page 84: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

https://developers.facebook.com/docs/plugins/like-button/

Page 85: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

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

Page 86: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

OPEN SOURCE INITIATIVES AND RESOURCES

Page 87: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

PRIVACY HERO HEISE’S OPT-IN SOLUTION

Page 88: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf#velocityconf

Page 89: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

3RD PARTY PERF HEROES PHILIP TELLIS & STOYAN STEFANOV

Page 90: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf#velocityconf

Page 91: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

MEASURING 3RD PARTY CONTENT ON YOUR SITE

Navigation timing APIResource timing API

Page 92: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

0

85

170

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

82 86 8699

130

157168

ADOPTION OF TIMING-ALLOW-ORIGIN HEADER (TOP ALEX WEBSITES)

#velocityconf

Facebook Google

Akamai Disqus Typekit Optimizely

Cedexis Twitter

CDNPlanet Walmart

Page 93: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

JSMANNERS

Page 94: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf#velocityconf

Page 95: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

CONTRIBUTE ON GITHUB!https://github.com/triblondon/thirdpartysla

#velocityconf

Page 96: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

NEXT TIME BEFORE YOU COPY AND PASTE

Page 97: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

WHAT TO DO AS A PUBLISHER & DEVELOPER

• 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

Page 98: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

• 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 99: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

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 100: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

THE PARTY’S OVER THANK YOU

Page 101: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

SHAMELESS PLUG I’m writing a book: Lean Websites (SitePoint)

VELOCITY OFFICE HOUR 2pm Table 1 (Sponsor Pavilion)

bit.ly/velocityconf14-3rdpartyQUESTIONS?

Page 102: Third Party Footprint: Evaluating the Performance of External Scripts

#velocityconf

BUT WHEN TO USE WHAT NOW?