SlideShare a Scribd company logo
Web Components
Diwakar Cherukumilli
Oswald Campesato
What are Web Components?
Web Components are a set of emerging standards that change the way web apps
are developed by reusing components in a much more efficient way
“A web app is a large collection of web components composed of many subelements,
known as custom elements” - Eric Bidelman
Why Web Components?
HTML at the beginning of the web
Small set of tags like:
● <select>
● <form>
● ….
These elements provided:
● Declarative
● Encapsulation
● Default UI
● Events
...
<select>
<option>One</option>
<option disabled>Two</option>
<option disabled>Three</option>
<option>Four</option>
<li>Five</li>
</select>
…
● Declarative
● Encapsulated
● Default UI
● NO JS :)
Modern Web apps without Web
Components
● Copy & paste chunks of HTML from CSS
libraries like Bootstrap
● All sorts of Javascript frameworks and plugins
● Reusing components from different frameworks
in the same page is not possible
○ Pages end up with bloated CSS and/or
Javascript
● Difficult to maintain
GMail code (in chrome developer tools)
Building a modern chart
Building a modern chart without web components
<head>
<!-- Load the google JS library to use the google visualization API -->
<script type=”text/javascript” src=”https://www.google.com/jsapi”></script>
</head>
<body>
<!-- Add the div tag as a placeholder for the chart -->
<div id=”char_div” style=”width:400; height: 300”></div>
</body>
Building a modern chart without web components
<!-- Using javascript -->
<!-- Load the visualization API -->
google.load(‘visualization’, ‘1.0’, {‘packages’: [‘corechart’]});
<!-- Set values and options on load callback -->
google.setOnLoadCallback(function() {
var data = new google.visualization.arrayToDataTable([[“Day”, “A”, “B”, “C”], [“Mon”, 20, 45, 28],
[“Tue”, 31, 66, 38], [“Wed”, 50, 80, 55], [“Thu”, 77, 50, 77], [“Fri”, 68, 15, 66]]);
var options =
{“seriesType”: “bars”, “series”: {“2”: {“type”: “line”}},
“width”: 400,
“height”: 300
};
<!-- Specify the dom element for the chart and draw it-->
var div = document.getElementById(‘chart_div’);
var chart = new google.visualization.ComboChart(div);
chart.draw(data, options);
});
Building a modern chart with web components
<head>
<!-- Load polyfill for cross browser support -->
<script src=”js/webcomponentjs.js”></script>
<!-- Import the google chart component -->
<link rel=”import” href=”components/google-chart.html”>
</head>
<body>
<!-- Add google chart tag and fill in the attributes -->
<google-chart
type=”combo”
height=”300px” width=”400px”
options=”{‘seriesType’: ‘bars’, ‘series’: {‘2’: {‘type’: ‘line’}}}”
data=”[[‘Day’, ‘A’, ‘B’, ‘C’], [‘Mon’, 20, 45, 28], [‘Tue’, 31, 66, 38], [‘Wed’, 50, 80, 55], [‘Thu’, 77, 50, 77], [‘Fri’, 68, 15, 66]]”>
</google-chart>
</body>
Declarative approach (with web
components)
<google-chart
type=”combo”
height=”300px”
width=”400px”
options=”{‘seriesType’: ‘bars’, ‘series’: {‘2’: {‘type’:
‘line’}}}”
data=”[[‘Day’, ‘A’, ‘B’, ‘C’], [‘Mon’, 20, 45, 28], [‘Tue’,
31, 66, 38], [‘Wed’, 50, 80, 55], [‘Thu’, 77, 50, 77], [‘Fri’,
68, 15, 66]]”>
</google-chart>
<!-- Easier to use -->
<!-- No need to know the underlying JS
API and CSS -->
Imperative Approach (without web
components)
google.load(‘visualization’, ‘1.0’, {‘packages’: [‘corechart’]});
google.setOnLoadCallback(function() {
var data = new google.visualization.
arrayToDataTable([[“Day”, “A”, “B”, “C”], [“Mon”, 20, 45,
28], [“Tue”, 31, 66, 38], [“Wed”, 50, 80, 55], [“Thu”, 77, 50,
77], [“Fri”, 68, 15, 66]]);
var options =
{“seriesType”: “bars”, “series”: {“2”: {“type”:
“line”}},
“width”: 400,
“height”: 300
};
var div = document.getElementById(‘chart_div’);
var chart = new google.visualization.ComboChart
(div);
chart.draw(data, options);
});
Scoped
Web components
● All mark up and CSS are scoped to the element
● Styles scoped to the element will not leak out to the parent
● Parent can’t style the web component accidentally
● Imported web components will not harm any part of your web page
Non Web Component based libraries
● Existing libraries that have same classes and id can cause styles to leak
Reusable
● Scoped and decoupled with the other parts of your web app
● Use same component in the other parts of your web app
● Use the component in another web app
● Publish your component as open source so that others can use it
Isolation
● Decouple development of web components from the rest of the web app as
they are scoped
● Maintenance of the web component is much easier due to isolation
Web Components is an umbrella term for four different
W3C specifications
● Custom Elements lets you define your own HTML tags
● HTML Templates enables you to define blocks of markup with the ability to
inject dynamic content into
● Shadow DOM gives you the ability to scope markup and styles in a separate
DOM tree
● HTML Imports provides a way to include and reuse HTML documents in other
HTML documents
Vanilla Web Component (svcc-component.html)
<template>
<p>This is svcc-component’s SHADOW DOM</p>
</template>
<script>
// 1. Register a custom element
var XElement = document.registerElement(‘svcc-component’, {
prototype: Object.create(HTMLElement.prototype, {
createCallback: {
value: function(){
// 2. Associate Shadow dom onto it
var root = this.createShadowRoot();
//3. Use templates to provide the contents of the shadow dom
var template = thisDoc.querySelector(‘#template’);
var content = thisDoc.importNode(template.content, true);
root.appendChild(content);
}
}
}
});
</script>
index.html
<html>
<head>
<!-- 4. Use HTML import to import the component-->
<link rel=”import” href=”svcc-component.html>
</head>
<body>
<svcc-component></svcc-component>
</body>
</html>
Polymer for buiding Web Components
Polymer lets you build
● encapsulated,
● re-usable elements
● that work just like HTML elements,
● to use in building web applications.
Polymer in 1 minute
/** * A not-very-useful inline element */
Polymer({
is: 'my-element'
});
Add markup to your element
<!-- define the markup that your element will use -->
<dom-module id="my-simple-namecard">
<template>
<div>
Hi! My name is <span>Jane</span>
</div>
</template>
<script>
Polymer({
is: 'my-simple-namecard'
});
</script>
</dom-module>
Configure properties on your element
// Create an element that takes a property
Polymer({
is: 'my-property-namecard',
properties: {
myName: {
type: String
}
},
ready: function() {
this.textContent = 'Hi! My name is ' + this.myName;
}
});
<!-- using the element -->
<my-property-namecard my-name="Jim"></my-property-namecard>
Hi! My name is Jim.
Bind data into your element using the
familiar mustache-syntax
<!-- define markup with bindings -->
<dom-module id="my-bound-namecard">
<template>
<div>
Hi! My name is <span>{{myName}}</span>
</div>
</template>
<script>
Polymer({
is: 'my-bound-namecard',
properties: {
myName: {
type: String
}
}
});
</script>
Hi! My name is Josh.
<!-- using the element -->
<my-bound-namecard my-name="Josh"></my-bound-namecard>
Bind data into your element using the
familiar mustache-syntax
<!-- define markup with bindings -->
<dom-module id="my-bound-namecard">
<template>
<div>
Hi! My name is <span>{{myName}}</span>
</div>
</template>
<script>
Polymer({
is: 'my-bound-namecard',
properties: {
myName: {
type: String
}
}
});
</script>
Hi! My name is Josh.
<!-- using the element -->
<my-bound-namecard my-name="Josh"></my-bound-namecard>
Style the internals of your element, without
the style leaking out
<!-- add style to your element -->
<dom-module id="my-styled-namecard">
<template>
<style>
/* This would be crazy in non webcomponents. */
span {font-weight: bold;}
</style>
<div>Hi! My name is <span>{{myName}}</span></div>
</template>
<script>
Polymer({
is: 'my-styled-namecard',
properties: {
myName: { type: String}
}
});
Hi! My name is Jesse.
<!-- using the element -->
<my-styled-namecard my-name="Jesse"></my-styled-namecard>
References...
Polymer - Chrome Dev Summit 2013 (Eric Bidelman)
Why Web Components (Zeno Rocha & Addy Osmani)?
DevBytes: Web Components - Overview (Eiji Katamura)
Polymer Github page (https://github.com/Polymer/polymer)
Ad

More Related Content

What's hot (20)

Web Components
Web ComponentsWeb Components
Web Components
Nikolaus Graf
 
ME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS Fundamentals
Aviran Cohen
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
Mike Wilcox
 
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
 
Introduction to Web Components
Introduction to Web ComponentsIntroduction to Web Components
Introduction to Web Components
Rich Bradshaw
 
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)
jskvara
 
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
crokitta
 
Angular js presentation at Datacom
Angular js presentation at DatacomAngular js presentation at Datacom
Angular js presentation at Datacom
David Xi Peng Yang
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJS
Infragistics
 
Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architecture
Michael He
 
Angular js 1.3 basic tutorial
Angular js 1.3 basic tutorialAngular js 1.3 basic tutorial
Angular js 1.3 basic tutorial
Al-Mutaz Bellah Salahat
 
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
sdeeg
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introduction
Luigi De Russis
 
Getting Started with Angular JS
Getting Started with Angular JSGetting Started with Angular JS
Getting Started with Angular JS
Akshay Mathur
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular js
Tamer Solieman
 
Web Components Everywhere
Web Components EverywhereWeb Components Everywhere
Web Components Everywhere
Ilia Idakiev
 
OpenCms Days 2015 Modern templates with nested containers
OpenCms Days 2015 Modern templates with nested containersOpenCms Days 2015 Modern templates with nested containers
OpenCms Days 2015 Modern templates with nested containers
Alkacon Software GmbH & Co. KG
 
Angular js
Angular jsAngular js
Angular js
Knoldus Inc.
 
Angular View Encapsulation
Angular View EncapsulationAngular View Encapsulation
Angular View Encapsulation
Jennifer Estrada
 
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
Rob Dodson
 
ME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS Fundamentals
Aviran Cohen
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
Mike Wilcox
 
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
 
Introduction to Web Components
Introduction to Web ComponentsIntroduction to Web Components
Introduction to Web Components
Rich Bradshaw
 
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)
jskvara
 
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
crokitta
 
Angular js presentation at Datacom
Angular js presentation at DatacomAngular js presentation at Datacom
Angular js presentation at Datacom
David Xi Peng Yang
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJS
Infragistics
 
Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architecture
Michael He
 
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
sdeeg
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introduction
Luigi De Russis
 
Getting Started with Angular JS
Getting Started with Angular JSGetting Started with Angular JS
Getting Started with Angular JS
Akshay Mathur
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular js
Tamer Solieman
 
Web Components Everywhere
Web Components EverywhereWeb Components Everywhere
Web Components Everywhere
Ilia Idakiev
 
OpenCms Days 2015 Modern templates with nested containers
OpenCms Days 2015 Modern templates with nested containersOpenCms Days 2015 Modern templates with nested containers
OpenCms Days 2015 Modern templates with nested containers
Alkacon Software GmbH & Co. KG
 
Angular View Encapsulation
Angular View EncapsulationAngular View Encapsulation
Angular View Encapsulation
Jennifer Estrada
 
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
Rob Dodson
 

Viewers also liked (17)

Red Hat - Sarangan Rangachari
Red Hat - Sarangan RangachariRed Hat - Sarangan Rangachari
Red Hat - Sarangan Rangachari
Inside Analysis
 
Drive It Home: A Roadmap for Today's Data-Driven Culture
Drive It Home: A Roadmap for Today's Data-Driven CultureDrive It Home: A Roadmap for Today's Data-Driven Culture
Drive It Home: A Roadmap for Today's Data-Driven Culture
Inside Analysis
 
DisrupTech - Robin Bloor (2)
DisrupTech - Robin Bloor (2)DisrupTech - Robin Bloor (2)
DisrupTech - Robin Bloor (2)
Inside Analysis
 
WebAction-Sami Abkay
WebAction-Sami AbkayWebAction-Sami Abkay
WebAction-Sami Abkay
Inside Analysis
 
แบบสำรวจ
แบบสำรวจแบบสำรวจ
แบบสำรวจ
NaCk Wanasanan
 
CV-MURUGAN PARAMASIVAM
CV-MURUGAN PARAMASIVAMCV-MURUGAN PARAMASIVAM
CV-MURUGAN PARAMASIVAM
Murugan Paramasivam
 
IT used by terrorists
IT used by terroristsIT used by terrorists
IT used by terrorists
cpandey76
 
The Postulate of Human Ecology
The Postulate of Human EcologyThe Postulate of Human Ecology
The Postulate of Human Ecology
Ernst Satvanyi
 
The Maturity Model: Taking the Growing Pains Out of Hadoop
The Maturity Model: Taking the Growing Pains Out of HadoopThe Maturity Model: Taking the Growing Pains Out of Hadoop
The Maturity Model: Taking the Growing Pains Out of Hadoop
Inside Analysis
 
Humanitarianism and volunteerism
Humanitarianism and volunteerismHumanitarianism and volunteerism
Humanitarianism and volunteerism
David Hii
 
Big Data Refinery: Distilling Value for User-Driven Analytics
Big Data Refinery: Distilling Value for User-Driven AnalyticsBig Data Refinery: Distilling Value for User-Driven Analytics
Big Data Refinery: Distilling Value for User-Driven Analytics
Inside Analysis
 
Understanding What’s Possible: Getting Business Value from Big Data Quickly
Understanding What’s Possible: Getting Business Value from Big Data QuicklyUnderstanding What’s Possible: Getting Business Value from Big Data Quickly
Understanding What’s Possible: Getting Business Value from Big Data Quickly
Inside Analysis
 
The Great Lakes: How to Approach a Big Data Implementation
The Great Lakes: How to Approach a Big Data ImplementationThe Great Lakes: How to Approach a Big Data Implementation
The Great Lakes: How to Approach a Big Data Implementation
Inside Analysis
 
Anthropometry presentation on height and weight measurement
Anthropometry presentation on height and weight measurementAnthropometry presentation on height and weight measurement
Anthropometry presentation on height and weight measurement
David Hii
 
Ford presentation
Ford presentationFord presentation
Ford presentation
Karen Diaz
 
What is Bitcoin? How Bitcoin works in under 5 minutes.
What is Bitcoin? How Bitcoin works in under 5 minutes.What is Bitcoin? How Bitcoin works in under 5 minutes.
What is Bitcoin? How Bitcoin works in under 5 minutes.
Ryan Shea
 
Red Hat - Sarangan Rangachari
Red Hat - Sarangan RangachariRed Hat - Sarangan Rangachari
Red Hat - Sarangan Rangachari
Inside Analysis
 
Drive It Home: A Roadmap for Today's Data-Driven Culture
Drive It Home: A Roadmap for Today's Data-Driven CultureDrive It Home: A Roadmap for Today's Data-Driven Culture
Drive It Home: A Roadmap for Today's Data-Driven Culture
Inside Analysis
 
DisrupTech - Robin Bloor (2)
DisrupTech - Robin Bloor (2)DisrupTech - Robin Bloor (2)
DisrupTech - Robin Bloor (2)
Inside Analysis
 
แบบสำรวจ
แบบสำรวจแบบสำรวจ
แบบสำรวจ
NaCk Wanasanan
 
IT used by terrorists
IT used by terroristsIT used by terrorists
IT used by terrorists
cpandey76
 
The Postulate of Human Ecology
The Postulate of Human EcologyThe Postulate of Human Ecology
The Postulate of Human Ecology
Ernst Satvanyi
 
The Maturity Model: Taking the Growing Pains Out of Hadoop
The Maturity Model: Taking the Growing Pains Out of HadoopThe Maturity Model: Taking the Growing Pains Out of Hadoop
The Maturity Model: Taking the Growing Pains Out of Hadoop
Inside Analysis
 
Humanitarianism and volunteerism
Humanitarianism and volunteerismHumanitarianism and volunteerism
Humanitarianism and volunteerism
David Hii
 
Big Data Refinery: Distilling Value for User-Driven Analytics
Big Data Refinery: Distilling Value for User-Driven AnalyticsBig Data Refinery: Distilling Value for User-Driven Analytics
Big Data Refinery: Distilling Value for User-Driven Analytics
Inside Analysis
 
Understanding What’s Possible: Getting Business Value from Big Data Quickly
Understanding What’s Possible: Getting Business Value from Big Data QuicklyUnderstanding What’s Possible: Getting Business Value from Big Data Quickly
Understanding What’s Possible: Getting Business Value from Big Data Quickly
Inside Analysis
 
The Great Lakes: How to Approach a Big Data Implementation
The Great Lakes: How to Approach a Big Data ImplementationThe Great Lakes: How to Approach a Big Data Implementation
The Great Lakes: How to Approach a Big Data Implementation
Inside Analysis
 
Anthropometry presentation on height and weight measurement
Anthropometry presentation on height and weight measurementAnthropometry presentation on height and weight measurement
Anthropometry presentation on height and weight measurement
David Hii
 
Ford presentation
Ford presentationFord presentation
Ford presentation
Karen Diaz
 
What is Bitcoin? How Bitcoin works in under 5 minutes.
What is Bitcoin? How Bitcoin works in under 5 minutes.What is Bitcoin? How Bitcoin works in under 5 minutes.
What is Bitcoin? How Bitcoin works in under 5 minutes.
Ryan Shea
 
Ad

Similar to Web components - An Introduction (20)

Polymer
Polymer Polymer
Polymer
jskvara
 
Internet protocol second unit IIPPT.pptx
Internet protocol second unit IIPPT.pptxInternet protocol second unit IIPPT.pptx
Internet protocol second unit IIPPT.pptx
ssuser92282c
 
Web Components: back to the future
Web Components: back to the futureWeb Components: back to the future
Web Components: back to the future
DA-14
 
Web components are the future of the web - Take advantage of new web technolo...
Web components are the future of the web - Take advantage of new web technolo...Web components are the future of the web - Take advantage of new web technolo...
Web components are the future of the web - Take advantage of new web technolo...
Marios Fakiolas
 
Unit 2 - Data Binding.pptx
Unit 2 - Data Binding.pptxUnit 2 - Data Binding.pptx
Unit 2 - Data Binding.pptx
Malla Reddy University
 
AngularJS
AngularJSAngularJS
AngularJS
Srivatsan Krishnamachari
 
Polymer and web component
Polymer and web componentPolymer and web component
Polymer and web component
Imam Raza
 
Polymer
PolymerPolymer
Polymer
LearningTech
 
"Umbraco MVC - a journey of discovery" - Lotte Pitcher
"Umbraco MVC - a journey of discovery" - Lotte Pitcher"Umbraco MVC - a journey of discovery" - Lotte Pitcher
"Umbraco MVC - a journey of discovery" - Lotte Pitcher
lottepitcher
 
Web Components for Java Developers
Web Components for Java DevelopersWeb Components for Java Developers
Web Components for Java Developers
Joonas Lehtinen
 
The Complementarity of React and Web Components
The Complementarity of React and Web ComponentsThe Complementarity of React and Web Components
The Complementarity of React and Web Components
Andrew Rota
 
Web component driven development
Web component driven developmentWeb component driven development
Web component driven development
Gil Fink
 
Web Components: Web back to future.
Web Components: Web back to future.Web Components: Web back to future.
Web Components: Web back to future.
GlobalLogic Ukraine
 
Lightning web components - Introduction, component Lifecycle, Events, decorat...
Lightning web components - Introduction, component Lifecycle, Events, decorat...Lightning web components - Introduction, component Lifecycle, Events, decorat...
Lightning web components - Introduction, component Lifecycle, Events, decorat...
Nidhi Sharma
 
Intro to MVC 3 for Government Developers
Intro to MVC 3 for Government DevelopersIntro to MVC 3 for Government Developers
Intro to MVC 3 for Government Developers
Frank La Vigne
 
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
Andrew Rota
 
Angular - Chapter 3 - Components
Angular - Chapter 3 - ComponentsAngular - Chapter 3 - Components
Angular - Chapter 3 - Components
WebStackAcademy
 
Web components api + Vuejs
Web components api + VuejsWeb components api + Vuejs
Web components api + Vuejs
Mikhail Kuznetcov
 
Building and Deployment of Drupal sites with Features and Context
Building and Deployment of Drupal sites with Features and ContextBuilding and Deployment of Drupal sites with Features and Context
Building and Deployment of Drupal sites with Features and Context
Svilen Sabev
 
Understanding the Web Page Layout
Understanding the Web Page LayoutUnderstanding the Web Page Layout
Understanding the Web Page Layout
Jhaun Paul Enriquez
 
Polymer
Polymer Polymer
Polymer
jskvara
 
Internet protocol second unit IIPPT.pptx
Internet protocol second unit IIPPT.pptxInternet protocol second unit IIPPT.pptx
Internet protocol second unit IIPPT.pptx
ssuser92282c
 
Web Components: back to the future
Web Components: back to the futureWeb Components: back to the future
Web Components: back to the future
DA-14
 
Web components are the future of the web - Take advantage of new web technolo...
Web components are the future of the web - Take advantage of new web technolo...Web components are the future of the web - Take advantage of new web technolo...
Web components are the future of the web - Take advantage of new web technolo...
Marios Fakiolas
 
Polymer and web component
Polymer and web componentPolymer and web component
Polymer and web component
Imam Raza
 
"Umbraco MVC - a journey of discovery" - Lotte Pitcher
"Umbraco MVC - a journey of discovery" - Lotte Pitcher"Umbraco MVC - a journey of discovery" - Lotte Pitcher
"Umbraco MVC - a journey of discovery" - Lotte Pitcher
lottepitcher
 
Web Components for Java Developers
Web Components for Java DevelopersWeb Components for Java Developers
Web Components for Java Developers
Joonas Lehtinen
 
The Complementarity of React and Web Components
The Complementarity of React and Web ComponentsThe Complementarity of React and Web Components
The Complementarity of React and Web Components
Andrew Rota
 
Web component driven development
Web component driven developmentWeb component driven development
Web component driven development
Gil Fink
 
Web Components: Web back to future.
Web Components: Web back to future.Web Components: Web back to future.
Web Components: Web back to future.
GlobalLogic Ukraine
 
Lightning web components - Introduction, component Lifecycle, Events, decorat...
Lightning web components - Introduction, component Lifecycle, Events, decorat...Lightning web components - Introduction, component Lifecycle, Events, decorat...
Lightning web components - Introduction, component Lifecycle, Events, decorat...
Nidhi Sharma
 
Intro to MVC 3 for Government Developers
Intro to MVC 3 for Government DevelopersIntro to MVC 3 for Government Developers
Intro to MVC 3 for Government Developers
Frank La Vigne
 
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
Andrew Rota
 
Angular - Chapter 3 - Components
Angular - Chapter 3 - ComponentsAngular - Chapter 3 - Components
Angular - Chapter 3 - Components
WebStackAcademy
 
Building and Deployment of Drupal sites with Features and Context
Building and Deployment of Drupal sites with Features and ContextBuilding and Deployment of Drupal sites with Features and Context
Building and Deployment of Drupal sites with Features and Context
Svilen Sabev
 
Understanding the Web Page Layout
Understanding the Web Page LayoutUnderstanding the Web Page Layout
Understanding the Web Page Layout
Jhaun Paul Enriquez
 
Ad

Recently uploaded (20)

Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
Egor Kaleynik
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)
Allon Mureinik
 
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AIScaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
danshalev
 
FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Maxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINKMaxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINK
younisnoman75
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
steaveroggers
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
Egor Kaleynik
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)
Allon Mureinik
 
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AIScaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
danshalev
 
FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Maxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINKMaxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINK
younisnoman75
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
steaveroggers
 

Web components - An Introduction

  • 2. What are Web Components? Web Components are a set of emerging standards that change the way web apps are developed by reusing components in a much more efficient way “A web app is a large collection of web components composed of many subelements, known as custom elements” - Eric Bidelman
  • 3. Why Web Components? HTML at the beginning of the web Small set of tags like: ● <select> ● <form> ● …. These elements provided: ● Declarative ● Encapsulation ● Default UI ● Events
  • 5. Modern Web apps without Web Components ● Copy & paste chunks of HTML from CSS libraries like Bootstrap ● All sorts of Javascript frameworks and plugins ● Reusing components from different frameworks in the same page is not possible ○ Pages end up with bloated CSS and/or Javascript ● Difficult to maintain GMail code (in chrome developer tools)
  • 7. Building a modern chart without web components <head> <!-- Load the google JS library to use the google visualization API --> <script type=”text/javascript” src=”https://www.google.com/jsapi”></script> </head> <body> <!-- Add the div tag as a placeholder for the chart --> <div id=”char_div” style=”width:400; height: 300”></div> </body>
  • 8. Building a modern chart without web components <!-- Using javascript --> <!-- Load the visualization API --> google.load(‘visualization’, ‘1.0’, {‘packages’: [‘corechart’]}); <!-- Set values and options on load callback --> google.setOnLoadCallback(function() { var data = new google.visualization.arrayToDataTable([[“Day”, “A”, “B”, “C”], [“Mon”, 20, 45, 28], [“Tue”, 31, 66, 38], [“Wed”, 50, 80, 55], [“Thu”, 77, 50, 77], [“Fri”, 68, 15, 66]]); var options = {“seriesType”: “bars”, “series”: {“2”: {“type”: “line”}}, “width”: 400, “height”: 300 }; <!-- Specify the dom element for the chart and draw it--> var div = document.getElementById(‘chart_div’); var chart = new google.visualization.ComboChart(div); chart.draw(data, options); });
  • 9. Building a modern chart with web components <head> <!-- Load polyfill for cross browser support --> <script src=”js/webcomponentjs.js”></script> <!-- Import the google chart component --> <link rel=”import” href=”components/google-chart.html”> </head> <body> <!-- Add google chart tag and fill in the attributes --> <google-chart type=”combo” height=”300px” width=”400px” options=”{‘seriesType’: ‘bars’, ‘series’: {‘2’: {‘type’: ‘line’}}}” data=”[[‘Day’, ‘A’, ‘B’, ‘C’], [‘Mon’, 20, 45, 28], [‘Tue’, 31, 66, 38], [‘Wed’, 50, 80, 55], [‘Thu’, 77, 50, 77], [‘Fri’, 68, 15, 66]]”> </google-chart> </body>
  • 10. Declarative approach (with web components) <google-chart type=”combo” height=”300px” width=”400px” options=”{‘seriesType’: ‘bars’, ‘series’: {‘2’: {‘type’: ‘line’}}}” data=”[[‘Day’, ‘A’, ‘B’, ‘C’], [‘Mon’, 20, 45, 28], [‘Tue’, 31, 66, 38], [‘Wed’, 50, 80, 55], [‘Thu’, 77, 50, 77], [‘Fri’, 68, 15, 66]]”> </google-chart> <!-- Easier to use --> <!-- No need to know the underlying JS API and CSS --> Imperative Approach (without web components) google.load(‘visualization’, ‘1.0’, {‘packages’: [‘corechart’]}); google.setOnLoadCallback(function() { var data = new google.visualization. arrayToDataTable([[“Day”, “A”, “B”, “C”], [“Mon”, 20, 45, 28], [“Tue”, 31, 66, 38], [“Wed”, 50, 80, 55], [“Thu”, 77, 50, 77], [“Fri”, 68, 15, 66]]); var options = {“seriesType”: “bars”, “series”: {“2”: {“type”: “line”}}, “width”: 400, “height”: 300 }; var div = document.getElementById(‘chart_div’); var chart = new google.visualization.ComboChart (div); chart.draw(data, options); });
  • 11. Scoped Web components ● All mark up and CSS are scoped to the element ● Styles scoped to the element will not leak out to the parent ● Parent can’t style the web component accidentally ● Imported web components will not harm any part of your web page Non Web Component based libraries ● Existing libraries that have same classes and id can cause styles to leak
  • 12. Reusable ● Scoped and decoupled with the other parts of your web app ● Use same component in the other parts of your web app ● Use the component in another web app ● Publish your component as open source so that others can use it
  • 13. Isolation ● Decouple development of web components from the rest of the web app as they are scoped ● Maintenance of the web component is much easier due to isolation
  • 14. Web Components is an umbrella term for four different W3C specifications ● Custom Elements lets you define your own HTML tags ● HTML Templates enables you to define blocks of markup with the ability to inject dynamic content into ● Shadow DOM gives you the ability to scope markup and styles in a separate DOM tree ● HTML Imports provides a way to include and reuse HTML documents in other HTML documents
  • 15. Vanilla Web Component (svcc-component.html) <template> <p>This is svcc-component’s SHADOW DOM</p> </template> <script> // 1. Register a custom element var XElement = document.registerElement(‘svcc-component’, { prototype: Object.create(HTMLElement.prototype, { createCallback: { value: function(){ // 2. Associate Shadow dom onto it var root = this.createShadowRoot(); //3. Use templates to provide the contents of the shadow dom var template = thisDoc.querySelector(‘#template’); var content = thisDoc.importNode(template.content, true); root.appendChild(content); } } } }); </script> index.html <html> <head> <!-- 4. Use HTML import to import the component--> <link rel=”import” href=”svcc-component.html> </head> <body> <svcc-component></svcc-component> </body> </html>
  • 16. Polymer for buiding Web Components Polymer lets you build ● encapsulated, ● re-usable elements ● that work just like HTML elements, ● to use in building web applications.
  • 17. Polymer in 1 minute /** * A not-very-useful inline element */ Polymer({ is: 'my-element' });
  • 18. Add markup to your element <!-- define the markup that your element will use --> <dom-module id="my-simple-namecard"> <template> <div> Hi! My name is <span>Jane</span> </div> </template> <script> Polymer({ is: 'my-simple-namecard' }); </script> </dom-module>
  • 19. Configure properties on your element // Create an element that takes a property Polymer({ is: 'my-property-namecard', properties: { myName: { type: String } }, ready: function() { this.textContent = 'Hi! My name is ' + this.myName; } }); <!-- using the element --> <my-property-namecard my-name="Jim"></my-property-namecard> Hi! My name is Jim.
  • 20. Bind data into your element using the familiar mustache-syntax <!-- define markup with bindings --> <dom-module id="my-bound-namecard"> <template> <div> Hi! My name is <span>{{myName}}</span> </div> </template> <script> Polymer({ is: 'my-bound-namecard', properties: { myName: { type: String } } }); </script> Hi! My name is Josh. <!-- using the element --> <my-bound-namecard my-name="Josh"></my-bound-namecard>
  • 21. Bind data into your element using the familiar mustache-syntax <!-- define markup with bindings --> <dom-module id="my-bound-namecard"> <template> <div> Hi! My name is <span>{{myName}}</span> </div> </template> <script> Polymer({ is: 'my-bound-namecard', properties: { myName: { type: String } } }); </script> Hi! My name is Josh. <!-- using the element --> <my-bound-namecard my-name="Josh"></my-bound-namecard>
  • 22. Style the internals of your element, without the style leaking out <!-- add style to your element --> <dom-module id="my-styled-namecard"> <template> <style> /* This would be crazy in non webcomponents. */ span {font-weight: bold;} </style> <div>Hi! My name is <span>{{myName}}</span></div> </template> <script> Polymer({ is: 'my-styled-namecard', properties: { myName: { type: String} } }); Hi! My name is Jesse. <!-- using the element --> <my-styled-namecard my-name="Jesse"></my-styled-namecard>
  • 23. References... Polymer - Chrome Dev Summit 2013 (Eric Bidelman) Why Web Components (Zeno Rocha & Addy Osmani)? DevBytes: Web Components - Overview (Eiji Katamura) Polymer Github page (https://github.com/Polymer/polymer)