SlideShare a Scribd company logo
Web Components 
What? Why? Polymer? 
Rich Bradshaw - Focal Strategy - @richbradshaw
Why do I care about this? 
• You are a HTML “user” - this will help you do more advanced things easily 
• You are a front end dev - you want to reuse components across sites/pages 
• You build single page apps (SPAs) and want a better way to organise things 
• You are interested in the direction that the web platform is heading
• What are the conventions of HTML? Plan 
• How do we build ‘components’ at the moment? 
• What are the limitations of the current approach? 
Questions/short break 
• What’s in the Web Components spec? 
• What components exist already? 
Questions/short break 
• What’s Polymer? 
• Let’s build an app using Polymer
Conventions in HTML
Elements can fire events, and have public properties
Elements are configured using attributes. 
Elements can be nested, and can only make sense 
if they are nested.
Some elements are not visual. 
Elements can have methods.
Some elements can provide complex behaviour.
Some elements have surprisingly complete 
APIs, that been there since, well, forever.
Summary 
Elements: 
• Are configured by attributes 
• Can fire events 
• Can have their own methods and properties 
• Are not always visible (e.g. meta, track, media) 
• Can be required to be within another element 
Check out: https://developer.mozilla.org/en-US/docs/Web/API
How do we build ‘components’ 
at the moment?
Component? 
• Self contained part of a page 
• Google Map, Youtube Video, 
Carousel, Accordion, Nav Bar………
+ some CSS in ‘global’ scope 
+ JS with public and private 
variables/methods 
jQuery Cycle
Google Maps
Advanced YouTube Embed
Problems 
• Not that user friendly ( jQuery isn’t bad) 
• Not easy to ensure assets aren’t loaded multiple times 
• Hard to link together 
• Hard for plugins to hide their CSS from the rest of the page
Inconsistency 
HTML Current Plugins 
Config Attributes Javascript 
Events Listen to element Listen to framework events 
Methods/Props On element From framework 
Interop Any framework Only same framework
Questions so far?
Web Components
Custom Elements HTML Imports 
Templates Shadow DOM 
BTW, there’s a polyfill for each - IE10+ and current version of all others
Shadow DOM 
Encapsulate the content of the DOM. Private JS/CSS for HTML.
A number input: Same ID in every instance 
Shadow DOM
Shadow DOM
Shadow DOM 
+ 
=
Browser support = 42.2% http://caniuse.com/#feat=shadowdom 
Shadow DOM
Templates 
Inert bits of HTML/CSS/JS that can be stamped out as needed. 
Like a native version of Handlebars/Mustache/Hogan.
Templates 
Broken image won’t cause 
error as this is inert 
Fill it in, stamp it out
+ 
You could now swap the template out without changing the page markup… 
Templates
Templates 
CSS Selectors
Browser support = 54.4% http://caniuse.com/#feat=template 
Templates
HTML Imports 
You can import CSS, JS, images, video and audio already - why 
not HTML?
How to load HTML 
• iframe = limited 
• ajax = OK but needs JS 
• pretending via <script type=‘x-template’>
Browser dedupes for you. Can be from another domain. 
Can be changed/created by JS. 
Content accessible via JS, ideal for templates. 
HTML Imports
Browser support = 35.3% http://caniuse.com/#feat=imports 
HTML Imports
Custom Elements 
Put all that together…
Custom Elements
Custom elements 
• Name must contain a dash 
• Default is to inherit from HTMLElement 
• Can extend native elements! 
• Can have methods, properties, events as native elements do 
• Can target unresolved elements to hide with CSS to avoid FOUC
Browser support = 38.4% http://caniuse.com/#feat=custom-elements 
Custom Elements
Existing Components
Really good list at: http://customelements.io/
Questions so far? 
http://webcomponents.org/ 
http://customelements.io/ 
http://caniuse.com/
Polymer
Polymer 
• Everything is an element 
• Comes with the basics (e.g. menus, buttons etc) 
• Two way data binding (on everything…) 
• Includes platform.js, polyfill for all we’ve talked about, 
object.observe, new web animation spec, pointer events and more.
Demo Time!
Find out more… 
• http://updates.html5rocks.com/tag/web-components 
• http://w3c.github.io/webcomponents/explainer/ 
• Spec: @coonsta, @dglazkov 
• Tools, articles: @ebidel, @addyosmani 
• Components Registry: http://customelements.io/ by @zenorocha 
• http://www.polymer-project.org/ 
• http://www.x-tags.org/, http://mozilla.github.io/brick/ 
• Freenode #webcomponents

More Related Content

What's hot

Google Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talkGoogle Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talk
Imam Raza
 
Polymer
Polymer Polymer
Polymer
jskvara
 

What's hot (20)

Google Polymer Introduction
Google Polymer IntroductionGoogle Polymer Introduction
Google Polymer Introduction
 
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
 
Levent-Gurses' Introduction to Web Components & Polymer
Levent-Gurses' Introduction to Web Components & PolymerLevent-Gurses' Introduction to Web Components & Polymer
Levent-Gurses' Introduction to Web Components & Polymer
 
Google Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talkGoogle Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talk
 
Polymer
PolymerPolymer
Polymer
 
Polymer
Polymer Polymer
Polymer
 
How to build a web application with Polymer
How to build a web application with PolymerHow to build a web application with Polymer
How to build a web application with Polymer
 
Introduction to polymer project
Introduction to polymer projectIntroduction to polymer project
Introduction to polymer project
 
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
 
Google Polymer Framework
Google Polymer FrameworkGoogle Polymer Framework
Google Polymer Framework
 
Web Components Everywhere
Web Components EverywhereWeb Components Everywhere
Web Components Everywhere
 
HTML5 Essential Training
HTML5 Essential TrainingHTML5 Essential Training
HTML5 Essential Training
 
The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17
The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17
The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17
 
Unlock the next era of UI design with Polymer
Unlock the next era of UI design with PolymerUnlock the next era of UI design with Polymer
Unlock the next era of UI design with Polymer
 
Web Components with Polymer (extra Polymer 2.0)
Web Components with Polymer (extra Polymer 2.0)Web Components with Polymer (extra Polymer 2.0)
Web Components with Polymer (extra Polymer 2.0)
 
Building a Secure App with Google Polymer and Java / Spring
Building a Secure App with Google Polymer and Java / SpringBuilding a Secure App with Google Polymer and Java / Spring
Building a Secure App with Google Polymer and Java / Spring
 
Polymer & the web components revolution 6:25:14
Polymer & the web components revolution 6:25:14Polymer & the web components revolution 6:25:14
Polymer & the web components revolution 6:25:14
 
Polymer vs other libraries (Devfest Ukraine 2015)
Polymer vs other libraries (Devfest Ukraine 2015)Polymer vs other libraries (Devfest Ukraine 2015)
Polymer vs other libraries (Devfest Ukraine 2015)
 
Web Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing CombinationWeb Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing Combination
 
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
 

Similar to Introduction to Web Components

Code &amp; design your first website (3:16)
Code &amp; design your first website (3:16)Code &amp; design your first website (3:16)
Code &amp; design your first website (3:16)
Thinkful
 
Html css crash course may 11th, atlanta
Html css crash course may 11th, atlantaHtml css crash course may 11th, atlanta
Html css crash course may 11th, atlanta
Thinkful
 

Similar to Introduction to Web Components (20)

HTML Semantic Tags
HTML Semantic TagsHTML Semantic Tags
HTML Semantic Tags
 
Web components, so close!
Web components, so close!Web components, so close!
Web components, so close!
 
Web Components at Scale, HTML5DevConf 2014-10-21
Web Components at Scale, HTML5DevConf 2014-10-21Web Components at Scale, HTML5DevConf 2014-10-21
Web Components at Scale, HTML5DevConf 2014-10-21
 
A practical guide to building websites with HTML5 & CSS3
A practical guide to building websites with HTML5 & CSS3A practical guide to building websites with HTML5 & CSS3
A practical guide to building websites with HTML5 & CSS3
 
Introduction to Webcomponents
Introduction to WebcomponentsIntroduction to Webcomponents
Introduction to Webcomponents
 
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentWordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
 
Web component driven development
Web component driven developmentWeb component driven development
Web component driven development
 
Code &amp; design your first website (3:16)
Code &amp; design your first website (3:16)Code &amp; design your first website (3:16)
Code &amp; design your first website (3:16)
 
HTML5 and Joomla! 2.5 Template
HTML5 and Joomla! 2.5 TemplateHTML5 and Joomla! 2.5 Template
HTML5 and Joomla! 2.5 Template
 
Frontend State of the union
Frontend State of the unionFrontend State of the union
Frontend State of the union
 
Html5
Html5Html5
Html5
 
High-Speed HTML5
High-Speed HTML5High-Speed HTML5
High-Speed HTML5
 
Html css crash course may 11th, atlanta
Html css crash course may 11th, atlantaHtml css crash course may 11th, atlanta
Html css crash course may 11th, atlanta
 
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
 
Curtin University Frontend Web Development
Curtin University Frontend Web DevelopmentCurtin University Frontend Web Development
Curtin University Frontend Web Development
 
Search Engine Optimization (Seo) for Developers
Search Engine Optimization (Seo) for DevelopersSearch Engine Optimization (Seo) for Developers
Search Engine Optimization (Seo) for Developers
 
Automated perf optimization - jQuery Conference
Automated perf optimization - jQuery ConferenceAutomated perf optimization - jQuery Conference
Automated perf optimization - jQuery Conference
 
Lightning web components
Lightning web componentsLightning web components
Lightning web components
 
Web Development with HTML5, CSS3 & JavaScript
Web Development with HTML5, CSS3 & JavaScriptWeb Development with HTML5, CSS3 & JavaScript
Web Development with HTML5, CSS3 & JavaScript
 
Code & Design your first website 4/18
Code & Design your first website 4/18Code & Design your first website 4/18
Code & Design your first website 4/18
 

Recently uploaded

Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Peter Udo Diehl
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 

Recently uploaded (20)

To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 

Introduction to Web Components

  • 1. Web Components What? Why? Polymer? Rich Bradshaw - Focal Strategy - @richbradshaw
  • 2. Why do I care about this? • You are a HTML “user” - this will help you do more advanced things easily • You are a front end dev - you want to reuse components across sites/pages • You build single page apps (SPAs) and want a better way to organise things • You are interested in the direction that the web platform is heading
  • 3. • What are the conventions of HTML? Plan • How do we build ‘components’ at the moment? • What are the limitations of the current approach? Questions/short break • What’s in the Web Components spec? • What components exist already? Questions/short break • What’s Polymer? • Let’s build an app using Polymer
  • 5. Elements can fire events, and have public properties
  • 6. Elements are configured using attributes. Elements can be nested, and can only make sense if they are nested.
  • 7. Some elements are not visual. Elements can have methods.
  • 8. Some elements can provide complex behaviour.
  • 9. Some elements have surprisingly complete APIs, that been there since, well, forever.
  • 10. Summary Elements: • Are configured by attributes • Can fire events • Can have their own methods and properties • Are not always visible (e.g. meta, track, media) • Can be required to be within another element Check out: https://developer.mozilla.org/en-US/docs/Web/API
  • 11. How do we build ‘components’ at the moment?
  • 12. Component? • Self contained part of a page • Google Map, Youtube Video, Carousel, Accordion, Nav Bar………
  • 13. + some CSS in ‘global’ scope + JS with public and private variables/methods jQuery Cycle
  • 16. Problems • Not that user friendly ( jQuery isn’t bad) • Not easy to ensure assets aren’t loaded multiple times • Hard to link together • Hard for plugins to hide their CSS from the rest of the page
  • 17. Inconsistency HTML Current Plugins Config Attributes Javascript Events Listen to element Listen to framework events Methods/Props On element From framework Interop Any framework Only same framework
  • 20. Custom Elements HTML Imports Templates Shadow DOM BTW, there’s a polyfill for each - IE10+ and current version of all others
  • 21. Shadow DOM Encapsulate the content of the DOM. Private JS/CSS for HTML.
  • 22. A number input: Same ID in every instance Shadow DOM
  • 25. Browser support = 42.2% http://caniuse.com/#feat=shadowdom Shadow DOM
  • 26. Templates Inert bits of HTML/CSS/JS that can be stamped out as needed. Like a native version of Handlebars/Mustache/Hogan.
  • 27. Templates Broken image won’t cause error as this is inert Fill it in, stamp it out
  • 28. + You could now swap the template out without changing the page markup… Templates
  • 30. Browser support = 54.4% http://caniuse.com/#feat=template Templates
  • 31. HTML Imports You can import CSS, JS, images, video and audio already - why not HTML?
  • 32. How to load HTML • iframe = limited • ajax = OK but needs JS • pretending via <script type=‘x-template’>
  • 33. Browser dedupes for you. Can be from another domain. Can be changed/created by JS. Content accessible via JS, ideal for templates. HTML Imports
  • 34. Browser support = 35.3% http://caniuse.com/#feat=imports HTML Imports
  • 35. Custom Elements Put all that together…
  • 37. Custom elements • Name must contain a dash • Default is to inherit from HTMLElement • Can extend native elements! • Can have methods, properties, events as native elements do • Can target unresolved elements to hide with CSS to avoid FOUC
  • 38. Browser support = 38.4% http://caniuse.com/#feat=custom-elements Custom Elements
  • 40. Really good list at: http://customelements.io/
  • 41. Questions so far? http://webcomponents.org/ http://customelements.io/ http://caniuse.com/
  • 43. Polymer • Everything is an element • Comes with the basics (e.g. menus, buttons etc) • Two way data binding (on everything…) • Includes platform.js, polyfill for all we’ve talked about, object.observe, new web animation spec, pointer events and more.
  • 44.
  • 46. Find out more… • http://updates.html5rocks.com/tag/web-components • http://w3c.github.io/webcomponents/explainer/ • Spec: @coonsta, @dglazkov • Tools, articles: @ebidel, @addyosmani • Components Registry: http://customelements.io/ by @zenorocha • http://www.polymer-project.org/ • http://www.x-tags.org/, http://mozilla.github.io/brick/ • Freenode #webcomponents