SlideShare una empresa de Scribd logo
1 de 64
Descargar para leer sin conexión
Web Components at Scale 
2014-10-20 
Chris Danford, @chrisdanford 
Pinterest Web Team
Topic Covered 
Pinterest’s evaluation of Web Components 
• Migrating from our existing component framework 
• SEO impact 
• Page load perf 
• Polyfill gotchas 
• Browser compatibility
Background Learnings Conclusion TODO
Background 
2 years since major design decisions made
Background 
Pinterest has grown 
Then 
7 engineers touching web 
Now 
70 engineers touching web
Background 
Architecture 
Web iOS 
Android 
API 
Search Datalayer 
Graph Service 
Client Apps 
Back-end 
Services ...
Background 
Web architecture 
Web server 
Routing 
Templates 
Render a component tree 
Behavior (event handlers) 
Duplication
Background 
Existing component system 
• Backbone View 
• Backbone Model 
• templates render to an HTML string, then innerHTML to 
load 
• re-rendering a subtree throws away the old subtree 
entirely
Style (.scss) 
Structure (.html) 
Behavior (.js)
from a template 
from JS
Background 
Web Components score card 
• Migrate gradually 
• Compatible with existing tooling 
• Content Security Policy 
• Page load performance (too much) 
• Don’t hurt SEO 
• Encapsulation of DOM and styles 
• Don’t cut off too many browser versions
Background Learnings Conclusion TODO
Migrate Gradually 
Custom Elements lifecycle functions 
Pinterest 
onCreated 
onAddedToDom 
onContentReady 
onRemovedFromDom 
Custom Elements 
createdCallback 
attachedCallback 
— 
detachedCallback 
Polymer 
created 
attached 
domReady 
detached
Quick prototype 
Each component renders itself in attachedCallback
Migrate Gradually
Preserve Existing Tools 
Can work with existing tooling 
• SASS 
• ESLint 
• Closure Compiler 
• Syntax-highlighting editors
Preserve Existing Tools 
External scripts and stylesheets are no problem 
• Polymer docs: Separating scripts from markup
Works with Existing Tooling
Don’t break Content Security Policy 
Polyfill problems 
• The HTML Imports polyfill loads imports using 
XMLHttpRequest then evals script
Requirements 
Content Security Policy 
• If you keep your styles and 
scripts external, there’s no 
action needed. 
• If you write inline styles or 
inline scripts, use the “csp” 
flag and Vulcanize will 
extract them to separate 
files. 
grunt.initConfig({ 
vulcanize: { 
options: { 
csp: true, 
... 
}, 
files: { 
'out.html': 'comps/**.html' 
}, 
}, 
});
Content Security Policy
Server-side Rendering 
• No story at all for Web Components/Polymer 
• If we can get away with it, we’d rather eliminate the Python 
code path for templates/rendering 
• What is the impact on 
• Page load times? 
• SEO?
Page Load Performance 
Nice to have 
• Not critical, but don’t want to regress more than 10-20%. 
• The median user has < 2 page refreshes per visit. Almost 
every interaction is a pushState. 
• Indirectly affects SEO (speed is a factor in scoring).
Page Load Performance 
Experiment 
• Control: Render the initial content sever-side in Python and 
send it as HTML in the page load 
• Treatment: Serve meta tags and correct HTTP response 
codes, but render all of the visible content in JS. 
• Measure using Web Page Test’s SpeedIndex - a measure of 
how early the final pixels are painted. Lower is better. 
• An explanation of SpeedIndex
Page Load Performance 
SpeedIndex, San Jose, DSL, Chrome 
Server-rendered JS-rendered Difference 
First View 5073 5236 3% 
Repeat View 2571 3114 20%
Page Load Performance 
A pleasant surprise!
SEO 
Important to not regress 
• Web doesn’t have the most active users of all the Pinterest 
client apps. 
• Web is the largest source of acquisition.
SEO 
Organic search traffic by source 
In practice, we are targeting Google crawler.
SEO 
Does Google’s crawler understand JS? 
Historically: “No” 
May 23, 2014: 
“we decided to try to (better) 
understand pages by executing 
JavaScript” 
-Google
SEO 
A/B test JS-rendered page 
• 10% of “Board” pages will render all of their components 
client-side 
• Takes Google roughly 1 week to re-index all content and for 
us to see the true impact
SEO 
5% decline in traffic vs. control group after only 1.5 days
SEO 
“Fetch as Google” 
• A tool in Google Webmaster Tools that 
shows what the crawler sees. 
Rendering pages with Fetch as Google 
post
• Crawler is seeing some 
client-rendered 
components. (yay!) 
• Content area of the 
page was blank. (boo) 
• An XHRs was needed 
to render the content, 
but the crawler 
blocked it. Eliminate 
the need for the XHR.
SEO 
Next experiment 
• Inline the data into the page to eliminate the XHR.
SEO 
But I’m optimistic!
DOM Encapsulation 
Shadow DOM 
It’s a heroic (crazy?) effort to make this 
work as a polyfill. 
Overrides 
• 20 methods on HTMLElement 
• 44 methods on Document 
• 69 element contructors
DOM Encapsulation 
Shadow DOM, continued 
Quirks 
• document, window, document.body, document.head 
can’t be wrapped by the polyfill, and you need to manually 
wrap: 
• wrap(document.body) 
• Console shortcuts to grab elements return the unwrapped 
element and need to be wrapped. 
• wrap($0)
Style Encapsulation 
Shadow CSS 
A style shimmer: re-writes CSS text with 
a bunch of regexes
Style Encapsulation 
Shadow CSS - what works 
• Replace :host with element selector 
• Add upper-bound encapsulation by prepending element 
selector
Style Encapsulation 
Easy with a CSS preprocessor too
Style Encapsulation 
Shadow CSS - limitations 
“For browsers that lack native support, Polymer’s polyfills 
attempt to shim some of the scoping behavior.” 
-Polyfill Details
Chrome 38 (native) Firefox 32 (polyfill)
Style Encapsulation 
Shadow CSS - limitations galore 
Can’t polyfill lower-bound encapsulation 
• Platform.ShadowCSS.strictStyling = true; 
• Requires that you add custom element’s name as an attribute 
on all DOM nodes in the shadowRoot e.g. <span x-foo> 
• Nobody is going to do that without a build step, so why bother 
polyfilling this at all?
Unless you like testing in different browsers 
• Force the Shadow DOM polyfill to be enabled.
Shadow DOM 
Shadow CSS
Browser Compatibility 
Polymer-stated support 
IE < 10 is hopeless 
Safari < 6 is hopeless 
https://www.polymer-project.org/resources/compatibility.html
Browser Compatibility 
Pinterest browsers by visitor 
5.05%+ of visitors incompatible
Browser Compatibility 
Pinterest browsers by visitor 
5.05%+ of visitors incompatible 9.25%+
Browser Compatibility 
Anecdotes 
• Android Browser 4.1 and 4.3 not 
working with any of the demos
Browser Compatibility 
Anecdotes 
• Chrome 37 crashes frequently 
with dev tools open making 
tweaks to the Polymer tutorial 
• iOS8 was broken well after the 
GM shipped and didn’t work until 
just before public launch
Browser Compat 
Anecdotes - IE10 
• the renderer process locks up on 
an unpatched IE10 (e.g. modern.ie 
image that has updates turned off)
Browser Compat 
Anecdotes - IE10 
10.0.10 10.0.20
Browser Compat 
Anecdotes - IE10 
• Can’t tell how many users this might impact because build # 
isn’t in the UA string.
Browser Compatibility
Background Learnings Conclusion TODO
Conclusion 
Migrate Gradually 
Works with Existing Tooling 
Content Security Policy 
Page Load Performance 
SEO 
Shadow DOM 
Shadow CSS 
Browser Compatibility
Polymer architecture 
Polymer.js 
• TemplateBinding 
• syntactic sugar 
(polymer-element 
tag, on-*event* 
attribute binding) 
• tooling (Vulcanize, 
Polymer Designer) 
core-elements 
paper-elements 
Platform.js 
“Prollyfills” 
• ShadowDOM 
• HTMLImports 
• Custom Elements 
• MutationObserver 
• Object.observe 
• menus 
• drawers 
• panels 
• animation 
framework
Background Learnings Conclusion TODO
Next Steps 
• SEO 
• eliminate the XHR, reset the experiment 
• Browser compatibility 
• try to measure impact on IE10 
• Pieces of platform.js that work on more browsers (Custom 
Elements?) 
• Finish evaluating other framework options
engineering.pinterest.com 
@chrisdanford
Web Components at Scale, HTML5DevConf 2014-10-21

Más contenido relacionado

La actualidad más candente

The Truth About Your Web App's Performance
The Truth About Your Web App's PerformanceThe Truth About Your Web App's Performance
The Truth About Your Web App's PerformanceJohn Riviello
 
Service workers your applications never felt so good
Service workers   your applications never felt so goodService workers   your applications never felt so good
Service workers your applications never felt so goodChris Love
 
Building Faster Websites
Building Faster WebsitesBuilding Faster Websites
Building Faster WebsitesCraig Walker
 
Custom Elements with Polymer Web Components #econfpsu16
Custom Elements with Polymer Web Components #econfpsu16Custom Elements with Polymer Web Components #econfpsu16
Custom Elements with Polymer Web Components #econfpsu16John Riviello
 
Disrupting the application eco system with progressive web applications
Disrupting the application eco system with progressive web applicationsDisrupting the application eco system with progressive web applications
Disrupting the application eco system with progressive web applicationsChris Love
 
WordPress Theme Performance - WP Vienna meetup 8.6.2016
WordPress Theme Performance - WP Vienna meetup 8.6.2016WordPress Theme Performance - WP Vienna meetup 8.6.2016
WordPress Theme Performance - WP Vienna meetup 8.6.2016jancbeck
 
Web performance optimization for modern web applications
Web performance optimization for modern web applicationsWeb performance optimization for modern web applications
Web performance optimization for modern web applicationsChris Love
 
Untangling - fall2017 - week 8
Untangling - fall2017 - week 8Untangling - fall2017 - week 8
Untangling - fall2017 - week 8Derek Jacoby
 
Happy Browser, Happy User! NY Web Performance Meetup 9/20/19
Happy Browser, Happy User! NY Web Performance Meetup 9/20/19Happy Browser, Happy User! NY Web Performance Meetup 9/20/19
Happy Browser, Happy User! NY Web Performance Meetup 9/20/19Katie Sylor-Miller
 
Untangling the web11
Untangling the web11Untangling the web11
Untangling the web11Derek Jacoby
 
Enough with the javas cript already! de Nicholas Zakas
Enough with the javas cript already! de Nicholas ZakasEnough with the javas cript already! de Nicholas Zakas
Enough with the javas cript already! de Nicholas ZakasKubide
 
Bringing HTML5 alive in SharePoint
Bringing HTML5 alive in SharePointBringing HTML5 alive in SharePoint
Bringing HTML5 alive in SharePointChad Schroeder
 
Introduction to jQuery - College Lecture
Introduction to jQuery - College LectureIntroduction to jQuery - College Lecture
Introduction to jQuery - College LectureZac Gordon
 
Build Reusable Web Components using HTML5 Web cComponents
Build Reusable Web Components using HTML5 Web cComponentsBuild Reusable Web Components using HTML5 Web cComponents
Build Reusable Web Components using HTML5 Web cComponentsGil Fink
 
Introduction to Web Components
Introduction to Web ComponentsIntroduction to Web Components
Introduction to Web ComponentsRich Bradshaw
 
Untangling the web week1
Untangling the web week1Untangling the web week1
Untangling the web week1Derek Jacoby
 
Untangling the web week 2 - SEO
Untangling the web week 2 - SEOUntangling the web week 2 - SEO
Untangling the web week 2 - SEODerek Jacoby
 
Modern web application devlopment workflow
Modern web application devlopment workflowModern web application devlopment workflow
Modern web application devlopment workflowHamdi Hmidi
 
Build Better Responsive websites. Hrvoje Jurišić
Build Better Responsive websites. Hrvoje JurišićBuild Better Responsive websites. Hrvoje Jurišić
Build Better Responsive websites. Hrvoje JurišićMeetMagentoNY2014
 

La actualidad más candente (20)

The Truth About Your Web App's Performance
The Truth About Your Web App's PerformanceThe Truth About Your Web App's Performance
The Truth About Your Web App's Performance
 
Service workers your applications never felt so good
Service workers   your applications never felt so goodService workers   your applications never felt so good
Service workers your applications never felt so good
 
Building Faster Websites
Building Faster WebsitesBuilding Faster Websites
Building Faster Websites
 
Custom Elements with Polymer Web Components #econfpsu16
Custom Elements with Polymer Web Components #econfpsu16Custom Elements with Polymer Web Components #econfpsu16
Custom Elements with Polymer Web Components #econfpsu16
 
Disrupting the application eco system with progressive web applications
Disrupting the application eco system with progressive web applicationsDisrupting the application eco system with progressive web applications
Disrupting the application eco system with progressive web applications
 
WordPress Theme Performance - WP Vienna meetup 8.6.2016
WordPress Theme Performance - WP Vienna meetup 8.6.2016WordPress Theme Performance - WP Vienna meetup 8.6.2016
WordPress Theme Performance - WP Vienna meetup 8.6.2016
 
Web performance optimization for modern web applications
Web performance optimization for modern web applicationsWeb performance optimization for modern web applications
Web performance optimization for modern web applications
 
Untangling - fall2017 - week 8
Untangling - fall2017 - week 8Untangling - fall2017 - week 8
Untangling - fall2017 - week 8
 
Happy Browser, Happy User! NY Web Performance Meetup 9/20/19
Happy Browser, Happy User! NY Web Performance Meetup 9/20/19Happy Browser, Happy User! NY Web Performance Meetup 9/20/19
Happy Browser, Happy User! NY Web Performance Meetup 9/20/19
 
Untangling the web11
Untangling the web11Untangling the web11
Untangling the web11
 
Enough with the javas cript already! de Nicholas Zakas
Enough with the javas cript already! de Nicholas ZakasEnough with the javas cript already! de Nicholas Zakas
Enough with the javas cript already! de Nicholas Zakas
 
Bringing HTML5 alive in SharePoint
Bringing HTML5 alive in SharePointBringing HTML5 alive in SharePoint
Bringing HTML5 alive in SharePoint
 
Introduction to jQuery - College Lecture
Introduction to jQuery - College LectureIntroduction to jQuery - College Lecture
Introduction to jQuery - College Lecture
 
Build Reusable Web Components using HTML5 Web cComponents
Build Reusable Web Components using HTML5 Web cComponentsBuild Reusable Web Components using HTML5 Web cComponents
Build Reusable Web Components using HTML5 Web cComponents
 
Introduction to Web Components
Introduction to Web ComponentsIntroduction to Web Components
Introduction to Web Components
 
Untangling the web week1
Untangling the web week1Untangling the web week1
Untangling the web week1
 
Mobile web performance dwx13
Mobile web performance dwx13Mobile web performance dwx13
Mobile web performance dwx13
 
Untangling the web week 2 - SEO
Untangling the web week 2 - SEOUntangling the web week 2 - SEO
Untangling the web week 2 - SEO
 
Modern web application devlopment workflow
Modern web application devlopment workflowModern web application devlopment workflow
Modern web application devlopment workflow
 
Build Better Responsive websites. Hrvoje Jurišić
Build Better Responsive websites. Hrvoje JurišićBuild Better Responsive websites. Hrvoje Jurišić
Build Better Responsive websites. Hrvoje Jurišić
 

Destacado

The Data Greenhouse DevOps Measurement at Scale
The Data Greenhouse  DevOps Measurement at ScaleThe Data Greenhouse  DevOps Measurement at Scale
The Data Greenhouse DevOps Measurement at Scalesparkagility
 
Ext. reading presentation novie
Ext. reading presentation novieExt. reading presentation novie
Ext. reading presentation novieYuLia Novietha
 
Scale & Measurement Module
Scale & Measurement ModuleScale & Measurement Module
Scale & Measurement ModuleAccessNano
 
Cost Components in a MW Scale Solar Power Project
Cost Components in a MW Scale Solar Power ProjectCost Components in a MW Scale Solar Power Project
Cost Components in a MW Scale Solar Power ProjectSrini Chopakatla, PE, PMP
 
Advantage and disadvantage of free trade and theorys of International trade law
Advantage and disadvantage of free trade and theorys of International trade lawAdvantage and disadvantage of free trade and theorys of International trade law
Advantage and disadvantage of free trade and theorys of International trade lawMd.saiful Islam
 
T4 measurement and scaling
T4 measurement and scalingT4 measurement and scaling
T4 measurement and scalingkompellark
 
Impact of globalization on small scale industries in
Impact of globalization on small scale industries inImpact of globalization on small scale industries in
Impact of globalization on small scale industries inAafaq Malik
 
Identify variable and measurement of scale
Identify variable and measurement of scaleIdentify variable and measurement of scale
Identify variable and measurement of scaleJanisha Gandhi
 
Thiyagu measurement scale
Thiyagu   measurement scaleThiyagu   measurement scale
Thiyagu measurement scaleThiyagu K
 
Visalia Public Opinion Survey PowerPoint
Visalia Public Opinion Survey PowerPointVisalia Public Opinion Survey PowerPoint
Visalia Public Opinion Survey PowerPointJUSTIN STONER
 
Economies of scale
Economies of scaleEconomies of scale
Economies of scaleanand2419
 
Economies Of Scale
Economies Of ScaleEconomies Of Scale
Economies Of Scaleguest9188c15
 
Advantage and Disadvantage of Social media
Advantage and Disadvantage of Social mediaAdvantage and Disadvantage of Social media
Advantage and Disadvantage of Social mediaSnehlata Maurya
 
Measurement and Scale
Measurement and ScaleMeasurement and Scale
Measurement and ScaleJohn Reiser
 
Measurement scales
Measurement scalesMeasurement scales
Measurement scalesAiden Yeh
 
Research Methodology - types of scale
Research Methodology - types of scaleResearch Methodology - types of scale
Research Methodology - types of scaleKarpagam Alagappan
 
Scales of Measurement
Scales of MeasurementScales of Measurement
Scales of Measurementloranel
 

Destacado (20)

The Data Greenhouse DevOps Measurement at Scale
The Data Greenhouse  DevOps Measurement at ScaleThe Data Greenhouse  DevOps Measurement at Scale
The Data Greenhouse DevOps Measurement at Scale
 
Ext. reading presentation novie
Ext. reading presentation novieExt. reading presentation novie
Ext. reading presentation novie
 
Scale & Measurement Module
Scale & Measurement ModuleScale & Measurement Module
Scale & Measurement Module
 
Measurement Scaling
Measurement ScalingMeasurement Scaling
Measurement Scaling
 
Cost Components in a MW Scale Solar Power Project
Cost Components in a MW Scale Solar Power ProjectCost Components in a MW Scale Solar Power Project
Cost Components in a MW Scale Solar Power Project
 
Measurements Theory
Measurements TheoryMeasurements Theory
Measurements Theory
 
Advantage and disadvantage of free trade and theorys of International trade law
Advantage and disadvantage of free trade and theorys of International trade lawAdvantage and disadvantage of free trade and theorys of International trade law
Advantage and disadvantage of free trade and theorys of International trade law
 
Self awareness
Self awarenessSelf awareness
Self awareness
 
T4 measurement and scaling
T4 measurement and scalingT4 measurement and scaling
T4 measurement and scaling
 
Impact of globalization on small scale industries in
Impact of globalization on small scale industries inImpact of globalization on small scale industries in
Impact of globalization on small scale industries in
 
Identify variable and measurement of scale
Identify variable and measurement of scaleIdentify variable and measurement of scale
Identify variable and measurement of scale
 
Thiyagu measurement scale
Thiyagu   measurement scaleThiyagu   measurement scale
Thiyagu measurement scale
 
Visalia Public Opinion Survey PowerPoint
Visalia Public Opinion Survey PowerPointVisalia Public Opinion Survey PowerPoint
Visalia Public Opinion Survey PowerPoint
 
Economies of scale
Economies of scaleEconomies of scale
Economies of scale
 
Economies Of Scale
Economies Of ScaleEconomies Of Scale
Economies Of Scale
 
Advantage and Disadvantage of Social media
Advantage and Disadvantage of Social mediaAdvantage and Disadvantage of Social media
Advantage and Disadvantage of Social media
 
Measurement and Scale
Measurement and ScaleMeasurement and Scale
Measurement and Scale
 
Measurement scales
Measurement scalesMeasurement scales
Measurement scales
 
Research Methodology - types of scale
Research Methodology - types of scaleResearch Methodology - types of scale
Research Methodology - types of scale
 
Scales of Measurement
Scales of MeasurementScales of Measurement
Scales of Measurement
 

Similar a Web Components at Scale, HTML5DevConf 2014-10-21

Cvcc performance tuning
Cvcc performance tuningCvcc performance tuning
Cvcc performance tuningJohn McCaffrey
 
Getting started with dev tools (4/10/17 DC)
Getting started with dev tools (4/10/17 DC)Getting started with dev tools (4/10/17 DC)
Getting started with dev tools (4/10/17 DC)Daniel Friedman
 
[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS
[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS
[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJSSrijan Technologies
 
Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Ganesh Kondal
 
PrairieDevCon 2014 - Web Doesn't Mean Slow
PrairieDevCon 2014 -  Web Doesn't Mean SlowPrairieDevCon 2014 -  Web Doesn't Mean Slow
PrairieDevCon 2014 - Web Doesn't Mean Slowdmethvin
 
Pearls and Must-Have Tools for the Modern Web / .NET Developer
Pearls and Must-Have Tools for the Modern Web / .NET DeveloperPearls and Must-Have Tools for the Modern Web / .NET Developer
Pearls and Must-Have Tools for the Modern Web / .NET DeveloperOfer Zelig
 
Web Components
Web ComponentsWeb Components
Web ComponentsFITC
 
Search Engine Optimization (Seo) for Developers
Search Engine Optimization (Seo) for DevelopersSearch Engine Optimization (Seo) for Developers
Search Engine Optimization (Seo) for DevelopersMatthew Robinson
 
5 Common Mistakes You are Making on your Website
 5 Common Mistakes You are Making on your Website 5 Common Mistakes You are Making on your Website
5 Common Mistakes You are Making on your WebsiteAcquia
 
Wessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdf
Wessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdfWessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdf
Wessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdfWessel Loth
 
L’importance du crawl du JavaScript : pourquoi, comment et pour quels bénéfic...
L’importance du crawl du JavaScript : pourquoi, comment et pour quels bénéfic...L’importance du crawl du JavaScript : pourquoi, comment et pour quels bénéfic...
L’importance du crawl du JavaScript : pourquoi, comment et pour quels bénéfic...SEO Camp Association
 
Does This Theme Make My Website Look Fat? (Wordcamp SLC 2013)
Does This Theme Make My Website Look Fat? (Wordcamp SLC 2013)Does This Theme Make My Website Look Fat? (Wordcamp SLC 2013)
Does This Theme Make My Website Look Fat? (Wordcamp SLC 2013)Adam Dunford
 
Optimization of modern web applications
Optimization of modern web applicationsOptimization of modern web applications
Optimization of modern web applicationsEugene Lazutkin
 
Training presentation.pptx
Training presentation.pptxTraining presentation.pptx
Training presentation.pptxNishchaiyaBayla1
 
Browsers. Magic is inside.
Browsers. Magic is inside.Browsers. Magic is inside.
Browsers. Magic is inside.Devexperts
 
A Day Building Fast, Responsive, Extensible Single Page Applications
A Day Building Fast, Responsive, Extensible Single Page ApplicationsA Day Building Fast, Responsive, Extensible Single Page Applications
A Day Building Fast, Responsive, Extensible Single Page ApplicationsChris Love
 

Similar a Web Components at Scale, HTML5DevConf 2014-10-21 (20)

Cvcc performance tuning
Cvcc performance tuningCvcc performance tuning
Cvcc performance tuning
 
Javascript for Wep Apps
Javascript for Wep AppsJavascript for Wep Apps
Javascript for Wep Apps
 
Web Performance Optimization (WPO)
Web Performance Optimization (WPO)Web Performance Optimization (WPO)
Web Performance Optimization (WPO)
 
Getting started with dev tools (4/10/17 DC)
Getting started with dev tools (4/10/17 DC)Getting started with dev tools (4/10/17 DC)
Getting started with dev tools (4/10/17 DC)
 
[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS
[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS
[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS
 
Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5
 
PrairieDevCon 2014 - Web Doesn't Mean Slow
PrairieDevCon 2014 -  Web Doesn't Mean SlowPrairieDevCon 2014 -  Web Doesn't Mean Slow
PrairieDevCon 2014 - Web Doesn't Mean Slow
 
Pearls and Must-Have Tools for the Modern Web / .NET Developer
Pearls and Must-Have Tools for the Modern Web / .NET DeveloperPearls and Must-Have Tools for the Modern Web / .NET Developer
Pearls and Must-Have Tools for the Modern Web / .NET Developer
 
Web Components
Web ComponentsWeb Components
Web Components
 
Search Engine Optimization (Seo) for Developers
Search Engine Optimization (Seo) for DevelopersSearch Engine Optimization (Seo) for Developers
Search Engine Optimization (Seo) for Developers
 
5 Common Mistakes You are Making on your Website
 5 Common Mistakes You are Making on your Website 5 Common Mistakes You are Making on your Website
5 Common Mistakes You are Making on your Website
 
Wessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdf
Wessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdfWessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdf
Wessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdf
 
L’importance du crawl du JavaScript : pourquoi, comment et pour quels bénéfic...
L’importance du crawl du JavaScript : pourquoi, comment et pour quels bénéfic...L’importance du crawl du JavaScript : pourquoi, comment et pour quels bénéfic...
L’importance du crawl du JavaScript : pourquoi, comment et pour quels bénéfic...
 
performance.ppt
performance.pptperformance.ppt
performance.ppt
 
Does This Theme Make My Website Look Fat? (Wordcamp SLC 2013)
Does This Theme Make My Website Look Fat? (Wordcamp SLC 2013)Does This Theme Make My Website Look Fat? (Wordcamp SLC 2013)
Does This Theme Make My Website Look Fat? (Wordcamp SLC 2013)
 
Dust.js
Dust.jsDust.js
Dust.js
 
Optimization of modern web applications
Optimization of modern web applicationsOptimization of modern web applications
Optimization of modern web applications
 
Training presentation.pptx
Training presentation.pptxTraining presentation.pptx
Training presentation.pptx
 
Browsers. Magic is inside.
Browsers. Magic is inside.Browsers. Magic is inside.
Browsers. Magic is inside.
 
A Day Building Fast, Responsive, Extensible Single Page Applications
A Day Building Fast, Responsive, Extensible Single Page ApplicationsA Day Building Fast, Responsive, Extensible Single Page Applications
A Day Building Fast, Responsive, Extensible Single Page Applications
 

Último

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
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 

Último (20)

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
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

Web Components at Scale, HTML5DevConf 2014-10-21

  • 1.
  • 2. Web Components at Scale 2014-10-20 Chris Danford, @chrisdanford Pinterest Web Team
  • 3. Topic Covered Pinterest’s evaluation of Web Components • Migrating from our existing component framework • SEO impact • Page load perf • Polyfill gotchas • Browser compatibility
  • 5. Background 2 years since major design decisions made
  • 6. Background Pinterest has grown Then 7 engineers touching web Now 70 engineers touching web
  • 7. Background Architecture Web iOS Android API Search Datalayer Graph Service Client Apps Back-end Services ...
  • 8. Background Web architecture Web server Routing Templates Render a component tree Behavior (event handlers) Duplication
  • 9. Background Existing component system • Backbone View • Backbone Model • templates render to an HTML string, then innerHTML to load • re-rendering a subtree throws away the old subtree entirely
  • 10. Style (.scss) Structure (.html) Behavior (.js)
  • 11. from a template from JS
  • 12. Background Web Components score card • Migrate gradually • Compatible with existing tooling • Content Security Policy • Page load performance (too much) • Don’t hurt SEO • Encapsulation of DOM and styles • Don’t cut off too many browser versions
  • 14. Migrate Gradually Custom Elements lifecycle functions Pinterest onCreated onAddedToDom onContentReady onRemovedFromDom Custom Elements createdCallback attachedCallback — detachedCallback Polymer created attached domReady detached
  • 15. Quick prototype Each component renders itself in attachedCallback
  • 17. Preserve Existing Tools Can work with existing tooling • SASS • ESLint • Closure Compiler • Syntax-highlighting editors
  • 18. Preserve Existing Tools External scripts and stylesheets are no problem • Polymer docs: Separating scripts from markup
  • 20. Don’t break Content Security Policy Polyfill problems • The HTML Imports polyfill loads imports using XMLHttpRequest then evals script
  • 21. Requirements Content Security Policy • If you keep your styles and scripts external, there’s no action needed. • If you write inline styles or inline scripts, use the “csp” flag and Vulcanize will extract them to separate files. grunt.initConfig({ vulcanize: { options: { csp: true, ... }, files: { 'out.html': 'comps/**.html' }, }, });
  • 23. Server-side Rendering • No story at all for Web Components/Polymer • If we can get away with it, we’d rather eliminate the Python code path for templates/rendering • What is the impact on • Page load times? • SEO?
  • 24. Page Load Performance Nice to have • Not critical, but don’t want to regress more than 10-20%. • The median user has < 2 page refreshes per visit. Almost every interaction is a pushState. • Indirectly affects SEO (speed is a factor in scoring).
  • 25. Page Load Performance Experiment • Control: Render the initial content sever-side in Python and send it as HTML in the page load • Treatment: Serve meta tags and correct HTTP response codes, but render all of the visible content in JS. • Measure using Web Page Test’s SpeedIndex - a measure of how early the final pixels are painted. Lower is better. • An explanation of SpeedIndex
  • 26. Page Load Performance SpeedIndex, San Jose, DSL, Chrome Server-rendered JS-rendered Difference First View 5073 5236 3% Repeat View 2571 3114 20%
  • 27. Page Load Performance A pleasant surprise!
  • 28. SEO Important to not regress • Web doesn’t have the most active users of all the Pinterest client apps. • Web is the largest source of acquisition.
  • 29. SEO Organic search traffic by source In practice, we are targeting Google crawler.
  • 30. SEO Does Google’s crawler understand JS? Historically: “No” May 23, 2014: “we decided to try to (better) understand pages by executing JavaScript” -Google
  • 31. SEO A/B test JS-rendered page • 10% of “Board” pages will render all of their components client-side • Takes Google roughly 1 week to re-index all content and for us to see the true impact
  • 32. SEO 5% decline in traffic vs. control group after only 1.5 days
  • 33. SEO “Fetch as Google” • A tool in Google Webmaster Tools that shows what the crawler sees. Rendering pages with Fetch as Google post
  • 34. • Crawler is seeing some client-rendered components. (yay!) • Content area of the page was blank. (boo) • An XHRs was needed to render the content, but the crawler blocked it. Eliminate the need for the XHR.
  • 35. SEO Next experiment • Inline the data into the page to eliminate the XHR.
  • 36. SEO But I’m optimistic!
  • 37. DOM Encapsulation Shadow DOM It’s a heroic (crazy?) effort to make this work as a polyfill. Overrides • 20 methods on HTMLElement • 44 methods on Document • 69 element contructors
  • 38. DOM Encapsulation Shadow DOM, continued Quirks • document, window, document.body, document.head can’t be wrapped by the polyfill, and you need to manually wrap: • wrap(document.body) • Console shortcuts to grab elements return the unwrapped element and need to be wrapped. • wrap($0)
  • 39. Style Encapsulation Shadow CSS A style shimmer: re-writes CSS text with a bunch of regexes
  • 40. Style Encapsulation Shadow CSS - what works • Replace :host with element selector • Add upper-bound encapsulation by prepending element selector
  • 41. Style Encapsulation Easy with a CSS preprocessor too
  • 42. Style Encapsulation Shadow CSS - limitations “For browsers that lack native support, Polymer’s polyfills attempt to shim some of the scoping behavior.” -Polyfill Details
  • 43. Chrome 38 (native) Firefox 32 (polyfill)
  • 44. Style Encapsulation Shadow CSS - limitations galore Can’t polyfill lower-bound encapsulation • Platform.ShadowCSS.strictStyling = true; • Requires that you add custom element’s name as an attribute on all DOM nodes in the shadowRoot e.g. <span x-foo> • Nobody is going to do that without a build step, so why bother polyfilling this at all?
  • 45.
  • 46. Unless you like testing in different browsers • Force the Shadow DOM polyfill to be enabled.
  • 48. Browser Compatibility Polymer-stated support IE < 10 is hopeless Safari < 6 is hopeless https://www.polymer-project.org/resources/compatibility.html
  • 49. Browser Compatibility Pinterest browsers by visitor 5.05%+ of visitors incompatible
  • 50. Browser Compatibility Pinterest browsers by visitor 5.05%+ of visitors incompatible 9.25%+
  • 51. Browser Compatibility Anecdotes • Android Browser 4.1 and 4.3 not working with any of the demos
  • 52. Browser Compatibility Anecdotes • Chrome 37 crashes frequently with dev tools open making tweaks to the Polymer tutorial • iOS8 was broken well after the GM shipped and didn’t work until just before public launch
  • 53. Browser Compat Anecdotes - IE10 • the renderer process locks up on an unpatched IE10 (e.g. modern.ie image that has updates turned off)
  • 54. Browser Compat Anecdotes - IE10 10.0.10 10.0.20
  • 55. Browser Compat Anecdotes - IE10 • Can’t tell how many users this might impact because build # isn’t in the UA string.
  • 58. Conclusion Migrate Gradually Works with Existing Tooling Content Security Policy Page Load Performance SEO Shadow DOM Shadow CSS Browser Compatibility
  • 59. Polymer architecture Polymer.js • TemplateBinding • syntactic sugar (polymer-element tag, on-*event* attribute binding) • tooling (Vulcanize, Polymer Designer) core-elements paper-elements Platform.js “Prollyfills” • ShadowDOM • HTMLImports • Custom Elements • MutationObserver • Object.observe • menus • drawers • panels • animation framework
  • 61. Next Steps • SEO • eliminate the XHR, reset the experiment • Browser compatibility • try to measure impact on IE10 • Pieces of platform.js that work on more browsers (Custom Elements?) • Finish evaluating other framework options
  • 62.