SlideShare a Scribd company logo
Web Components are the
future of the web
Take advantage of new web technologies using PolymerJS
Fakiolas Marios - fakiolasmarios@gmail.com / @fakiolinho
Frontend Developer at mist.io
What are Web Components then?
Web Components Introduction
Web Components are a set of standards currently being produced as a W3C
specification that allow for the creation of reusable widgets in web documents.
They are part of the browser, and so they do not need external libraries like
jQuery or Dojo.
With a Web Component, you can do almost anything that can be done with
HTML, CSS and JavaScript, and it can be a portable component that can be re-
used easily.
Web Components Basic Ingredients
Web Components use following technologies:
● HTML Templates
● Shadow DOM
● Custom Elements
● HTML Imports
Each of them can be used separately but combined with the rest gives us Web
Components technology.
HTML Templates
The HTML template element <template> is a mechanism for holding client-
side content that is not to be rendered when a page is loaded but may
subsequently be instantiated during runtime using JavaScript.
Think of a template as a content fragment that is being stored for subsequent
use in the document. While the parser does process the contents of the
<template> element while loading the page, it does so only to ensure that
those contents are valid; the element's contents are not rendered, however.
HTML Templates (example)
<ul id="users-list"></ul>
<template id="user-item">
<li>
<span id="user-name"></span>
</li>
</template>
HTML Templates (example)
var t = document.querySelector('#user-item');
t.content.querySelector("#user-name").textContent = "Fakiolas Marios";
// Clone the new li and insert it into the ul
var list = document.querySelector("#users-list");
var clone = document.importNode(t.content, true);
list[0].appendChild(clone);
Shadow DOM
Shadow DOM provides encapsulation for the JavaScript, CSS, and templating
in a Web Component. Shadow DOM makes it so these things remain separate
from the DOM of the main document. You can also use Shadow DOM by itself,
outside of a web component.
Why would you want to keep some code separate from the rest of the page?
One reason is that on a large site, for example, if the CSS is not carefully
organized, the styling for the navigation can "leak" into the main content area
where it was not intended to go, or vice-versa. As a site or an app scales, this
kind of thing becomes difficult to avoid.
Shadow DOM (example)
<html>
<head></head>
<body>
<p id="hostElement"></p>
<script>
...
</script>
</body>
</html>
Shadow DOM (example)
var shadow = document.querySelector('#hostElement').
createShadowRoot();
shadow.innerHTML = '<p>Here is some new text</p>';
shadow.innerHTML += '<style>p { color: red; }</style>';
Custom Elements
Custom Elements is a capability for creating your own custom HTML tags and
elements.
They can have their own scripted behavior and CSS styling.
They are part of Web Components but they can also be used by themselves.
<user-element data-url="http://someAvatar.com"></user-element>
Custom Elements (example)
var UserElementProto = Object.create(HTMLElement.prototype);
UserElementProto.createdCallback = function() {
var shadow = this.createShadowRoot();
var img = document.createElement('img');
img.url = this.getAttribute('data-url');
shadow.appendChild(img);
};
var UserElement = document.registerElement('user-element', {
prototype: UserElementProto
});
HTML Imports
HTML Imports is intended to be the packaging mechanism for Web
Components
Load it in your HTML5 just once:
<link rel="import" href="user-element.html">
Call it into action when you need it:
<user-element data-url="http://someAvatar.com"></user-element>
Web Components are awesome right?
Web Components support is limited yet
Custom Elements Support (1st of March 2016)
Shadow DOM Support (1st of March 2016)
HTML Imports Support (1st of March 2016)
HTML Templates Support (1st of March 2016)
Hmm, can i use Web Components today?
There is a solution!!!!
Use Web Components through Polymer
Polymer is the solution
What is Polymer?
Polymer is an open source js library supported officially by Google.
Since Web Components are not supported 100% yet, Polymer binds the gap by
using webcomponents.js polyfills. Also it offers a great variety of features and
utilities (2-way data-binding, observations, computed properties etc) so we can
build Rich Internet Applications with Web Components today.
It is hosted on Github since October of 2012 and at the moment (1st of March
2016) Polymer has 14.400 stars.
Its first stable 1.0 version was released in 2015 (28th of May 2015).
How Polymer works?
The Polymer library is designed to make it easier and faster for developers to
create great, reusable components for the modern web.
Polymer is built on top of the web components standards and it helps you build
your own custom elements.
Web Components Primitives
These standards provide the primitives you need to build new components.
You can build your own custom elements using these primitives, but it can be a
lot of work (we saw some vanilla js examples before).
Not all browsers support these standards yet, so the web components polyfill
library fills the gaps, implementing the APIs in JavaScript.
Polymer Library
Provides a declarative syntax that makes it simpler to define custom elements.
And it adds features like templating, two-way data binding and property
observation to help you build powerful, reusable elements with less code.
Custom Elements
If you don’t want to write your own elements, there are a number of elements
built with Polymer that you can drop straight into your existing pages. These
elements depend on the Polymer library, but you can use the elements without
using Polymer directly.
You can mix and match elements built with Polymer with other custom
elements, as well as built-in elements. The Polymer team has written
collections of elements that you can use in your apps.
Polymer Catalog (built in elements)
Polymer Google Web Components closer look
Use google-map element to show a simple map of Greece
<!-- Polyfill Web Components support for older browsers -->
<script src="components/webcomponentsjs/webcomponents-lite.min.js"></script>
<!-- Import element -->
<link rel="import" href="components/google-map/google-map.html">
<!-- Use element -->
<google-map latitude="38.605225" longitude="24.645403"></google-map>
Use google-map element adding some custom markers
<google-map latitude="38.605225" longitude="24.645403" fit-to-markers>
<google-map-marker latitude="37.969406" longitude="23.720744" title="
Hello Athens!"></google-map-marker>
<google-map-marker latitude="39.104739" longitude="26.557254" title="
Hello Mitilini!"></google-map-marker>
</google-map>
Create a custom element with Polymer
<dom-module id="user-element">
<style>...</style>
<template>
<img src="[[url]]" />
</template>
<script>
Polymer({
is: 'user-element',
properties: {
url: String
}
});
</script>
</dom-module>
Use our custom element
<!-- Polyfill Web Components support for older browsers -->
<script src="components/webcomponentsjs/webcomponents-lite.min.js"></script>
<!-- Import element -->
<link rel="import" href="components/user-element.html">
<!-- Use element -->
<user-element url="http://someAvatar.com"></user-element>
Web components are the future of the web - Take advantage of new web technologies using PolymerJS

More Related Content

What's hot

What's hot (20)

Angular 4 fronts
Angular 4 frontsAngular 4 fronts
Angular 4 fronts
 
Dive into Angular, part 4: Angular 2.0
Dive into Angular, part 4: Angular 2.0Dive into Angular, part 4: Angular 2.0
Dive into Angular, part 4: Angular 2.0
 
Angular 4 and TypeScript
Angular 4 and TypeScriptAngular 4 and TypeScript
Angular 4 and TypeScript
 
Developing a Demo Application with Angular 4 - J2I
Developing a Demo Application with Angular 4 - J2IDeveloping a Demo Application with Angular 4 - J2I
Developing a Demo Application with Angular 4 - J2I
 
Introduction to angular 2
Introduction to angular 2Introduction to angular 2
Introduction to angular 2
 
Angular tutorial
Angular tutorialAngular tutorial
Angular tutorial
 
Top 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular AppTop 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular App
 
Angular IO
Angular IOAngular IO
Angular IO
 
Angular 9
Angular 9 Angular 9
Angular 9
 
Angular 5
Angular 5Angular 5
Angular 5
 
Angular js
Angular jsAngular js
Angular js
 
What angular 13 will bring to the table
What angular 13 will bring to the table What angular 13 will bring to the table
What angular 13 will bring to the table
 
Introduction To Angular 4 - J2I
Introduction To Angular 4 - J2IIntroduction To Angular 4 - J2I
Introduction To Angular 4 - J2I
 
AngularJS2 / TypeScript / CLI
AngularJS2 / TypeScript / CLIAngularJS2 / TypeScript / CLI
AngularJS2 / TypeScript / CLI
 
Angular 10 course_content
Angular 10 course_contentAngular 10 course_content
Angular 10 course_content
 
AngularJS
AngularJSAngularJS
AngularJS
 
Angular 2
Angular 2Angular 2
Angular 2
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2
 
Angular 2 - Better or worse
Angular 2 - Better or worseAngular 2 - Better or worse
Angular 2 - Better or worse
 
Angular from Scratch
Angular from ScratchAngular from Scratch
Angular from Scratch
 

Viewers also liked

Viewers also liked (9)

Web Components: Rethinking Web App Development
Web Components: Rethinking Web App DevelopmentWeb Components: Rethinking Web App Development
Web Components: Rethinking Web App Development
 
MAppMechanic CodeLabs - PolymerJS Elements - Paper, Gold, Neon, Platinum, Mol...
MAppMechanic CodeLabs - PolymerJS Elements - Paper, Gold, Neon, Platinum, Mol...MAppMechanic CodeLabs - PolymerJS Elements - Paper, Gold, Neon, Platinum, Mol...
MAppMechanic CodeLabs - PolymerJS Elements - Paper, Gold, Neon, Platinum, Mol...
 
MAppMechanic CodeLabs - PolymerJS Advanced Topics for Custom Elements
MAppMechanic CodeLabs - PolymerJS Advanced Topics for Custom ElementsMAppMechanic CodeLabs - PolymerJS Advanced Topics for Custom Elements
MAppMechanic CodeLabs - PolymerJS Advanced Topics for Custom Elements
 
MAppMechanic CodeLabs - PolymerJS Introduction
MAppMechanic CodeLabs - PolymerJS IntroductionMAppMechanic CodeLabs - PolymerJS Introduction
MAppMechanic CodeLabs - PolymerJS Introduction
 
New World of Angular (v2+)
New World of Angular (v2+)New World of Angular (v2+)
New World of Angular (v2+)
 
Intro to Web Components, Polymer & Vaadin Elements
Intro to Web Components, Polymer & Vaadin ElementsIntro to Web Components, Polymer & Vaadin Elements
Intro to Web Components, Polymer & Vaadin Elements
 
PolymerJS 開發實戰
PolymerJS 開發實戰PolymerJS 開發實戰
PolymerJS 開發實戰
 
MAppMechanic CodeLabs - PolymerJS Custom Elements
MAppMechanic CodeLabs - PolymerJS Custom ElementsMAppMechanic CodeLabs - PolymerJS Custom Elements
MAppMechanic CodeLabs - PolymerJS Custom Elements
 
Polymer ppt
Polymer pptPolymer ppt
Polymer ppt
 

Similar to Web components are the future of the web - Take advantage of new web technologies using PolymerJS

Is it time to start using HTML 5
Is it time to start using HTML 5Is it time to start using HTML 5
Is it time to start using HTML 5
Ravi Raj
 

Similar to Web components are the future of the web - Take advantage of new web technologies using PolymerJS (20)

Webcomponents v2
Webcomponents v2Webcomponents v2
Webcomponents v2
 
Web components Introduction
Web components IntroductionWeb components Introduction
Web components Introduction
 
Web components api + Vuejs
Web components api + VuejsWeb components api + Vuejs
Web components api + Vuejs
 
Leveraging the Power of Custom Elements in Gutenberg
Leveraging the Power of Custom Elements in GutenbergLeveraging the Power of Custom Elements in Gutenberg
Leveraging the Power of Custom Elements in Gutenberg
 
Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introduction
 
IRJET- Polymer Javascript
IRJET- Polymer JavascriptIRJET- Polymer Javascript
IRJET- Polymer Javascript
 
Web components
Web componentsWeb components
Web components
 
Web Components: back to the future
Web Components: back to the futureWeb Components: back to the future
Web Components: back to the future
 
Html5 basics
Html5 basicsHtml5 basics
Html5 basics
 
JEE Conf 2015: Less JS!
JEE Conf 2015: Less JS!JEE Conf 2015: Less JS!
JEE Conf 2015: Less JS!
 
Getting started with html5
Getting started with html5Getting started with html5
Getting started with html5
 
Building reusable components as micro frontends with glimmer js and webcompo...
Building reusable components as micro frontends  with glimmer js and webcompo...Building reusable components as micro frontends  with glimmer js and webcompo...
Building reusable components as micro frontends with glimmer js and webcompo...
 
Is it time to start using HTML 5
Is it time to start using HTML 5Is it time to start using HTML 5
Is it time to start using HTML 5
 
Webcomponents TLV October 2014
Webcomponents TLV October 2014Webcomponents TLV October 2014
Webcomponents TLV October 2014
 
Wa html5-pdf
Wa html5-pdfWa html5-pdf
Wa html5-pdf
 
Wa html5-pdf
Wa html5-pdfWa html5-pdf
Wa html5-pdf
 
Html5
Html5Html5
Html5
 
Web Components: Web back to future.
Web Components: Web back to future.Web Components: Web back to future.
Web Components: Web back to future.
 
Polymer 101
Polymer 101Polymer 101
Polymer 101
 
Web Components
Web ComponentsWeb Components
Web Components
 

Recently uploaded

RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
Atif Razi
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
Online blood donation management system project.pdf
Online blood donation management system project.pdfOnline blood donation management system project.pdf
Online blood donation management system project.pdf
Kamal Acharya
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
Kamal Acharya
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 

Recently uploaded (20)

RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
 
İTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopİTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering Workshop
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Danfoss NeoCharge Technology -A Revolution in 2024.pdf
Danfoss NeoCharge Technology -A Revolution in 2024.pdfDanfoss NeoCharge Technology -A Revolution in 2024.pdf
Danfoss NeoCharge Technology -A Revolution in 2024.pdf
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
Online blood donation management system project.pdf
Online blood donation management system project.pdfOnline blood donation management system project.pdf
Online blood donation management system project.pdf
 
Natalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in KrakówNatalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in Kraków
 
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
 
ENERGY STORAGE DEVICES INTRODUCTION UNIT-I
ENERGY STORAGE DEVICES  INTRODUCTION UNIT-IENERGY STORAGE DEVICES  INTRODUCTION UNIT-I
ENERGY STORAGE DEVICES INTRODUCTION UNIT-I
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
 
fundamentals of drawing and isometric and orthographic projection
fundamentals of drawing and isometric and orthographic projectionfundamentals of drawing and isometric and orthographic projection
fundamentals of drawing and isometric and orthographic projection
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
shape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptxshape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptx
 
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
 

Web components are the future of the web - Take advantage of new web technologies using PolymerJS

  • 1. Web Components are the future of the web Take advantage of new web technologies using PolymerJS Fakiolas Marios - fakiolasmarios@gmail.com / @fakiolinho Frontend Developer at mist.io
  • 2. What are Web Components then?
  • 3. Web Components Introduction Web Components are a set of standards currently being produced as a W3C specification that allow for the creation of reusable widgets in web documents. They are part of the browser, and so they do not need external libraries like jQuery or Dojo. With a Web Component, you can do almost anything that can be done with HTML, CSS and JavaScript, and it can be a portable component that can be re- used easily.
  • 4. Web Components Basic Ingredients Web Components use following technologies: ● HTML Templates ● Shadow DOM ● Custom Elements ● HTML Imports Each of them can be used separately but combined with the rest gives us Web Components technology.
  • 5. HTML Templates The HTML template element <template> is a mechanism for holding client- side content that is not to be rendered when a page is loaded but may subsequently be instantiated during runtime using JavaScript. Think of a template as a content fragment that is being stored for subsequent use in the document. While the parser does process the contents of the <template> element while loading the page, it does so only to ensure that those contents are valid; the element's contents are not rendered, however.
  • 6. HTML Templates (example) <ul id="users-list"></ul> <template id="user-item"> <li> <span id="user-name"></span> </li> </template>
  • 7. HTML Templates (example) var t = document.querySelector('#user-item'); t.content.querySelector("#user-name").textContent = "Fakiolas Marios"; // Clone the new li and insert it into the ul var list = document.querySelector("#users-list"); var clone = document.importNode(t.content, true); list[0].appendChild(clone);
  • 8. Shadow DOM Shadow DOM provides encapsulation for the JavaScript, CSS, and templating in a Web Component. Shadow DOM makes it so these things remain separate from the DOM of the main document. You can also use Shadow DOM by itself, outside of a web component. Why would you want to keep some code separate from the rest of the page? One reason is that on a large site, for example, if the CSS is not carefully organized, the styling for the navigation can "leak" into the main content area where it was not intended to go, or vice-versa. As a site or an app scales, this kind of thing becomes difficult to avoid.
  • 9. Shadow DOM (example) <html> <head></head> <body> <p id="hostElement"></p> <script> ... </script> </body> </html>
  • 10. Shadow DOM (example) var shadow = document.querySelector('#hostElement'). createShadowRoot(); shadow.innerHTML = '<p>Here is some new text</p>'; shadow.innerHTML += '<style>p { color: red; }</style>';
  • 11. Custom Elements Custom Elements is a capability for creating your own custom HTML tags and elements. They can have their own scripted behavior and CSS styling. They are part of Web Components but they can also be used by themselves. <user-element data-url="http://someAvatar.com"></user-element>
  • 12. Custom Elements (example) var UserElementProto = Object.create(HTMLElement.prototype); UserElementProto.createdCallback = function() { var shadow = this.createShadowRoot(); var img = document.createElement('img'); img.url = this.getAttribute('data-url'); shadow.appendChild(img); }; var UserElement = document.registerElement('user-element', { prototype: UserElementProto });
  • 13. HTML Imports HTML Imports is intended to be the packaging mechanism for Web Components Load it in your HTML5 just once: <link rel="import" href="user-element.html"> Call it into action when you need it: <user-element data-url="http://someAvatar.com"></user-element>
  • 14. Web Components are awesome right?
  • 15. Web Components support is limited yet
  • 16. Custom Elements Support (1st of March 2016)
  • 17. Shadow DOM Support (1st of March 2016)
  • 18. HTML Imports Support (1st of March 2016)
  • 19. HTML Templates Support (1st of March 2016)
  • 20. Hmm, can i use Web Components today? There is a solution!!!!
  • 21. Use Web Components through Polymer Polymer is the solution
  • 22. What is Polymer? Polymer is an open source js library supported officially by Google. Since Web Components are not supported 100% yet, Polymer binds the gap by using webcomponents.js polyfills. Also it offers a great variety of features and utilities (2-way data-binding, observations, computed properties etc) so we can build Rich Internet Applications with Web Components today. It is hosted on Github since October of 2012 and at the moment (1st of March 2016) Polymer has 14.400 stars. Its first stable 1.0 version was released in 2015 (28th of May 2015).
  • 23. How Polymer works? The Polymer library is designed to make it easier and faster for developers to create great, reusable components for the modern web. Polymer is built on top of the web components standards and it helps you build your own custom elements.
  • 24. Web Components Primitives These standards provide the primitives you need to build new components. You can build your own custom elements using these primitives, but it can be a lot of work (we saw some vanilla js examples before). Not all browsers support these standards yet, so the web components polyfill library fills the gaps, implementing the APIs in JavaScript.
  • 25. Polymer Library Provides a declarative syntax that makes it simpler to define custom elements. And it adds features like templating, two-way data binding and property observation to help you build powerful, reusable elements with less code.
  • 26. Custom Elements If you don’t want to write your own elements, there are a number of elements built with Polymer that you can drop straight into your existing pages. These elements depend on the Polymer library, but you can use the elements without using Polymer directly. You can mix and match elements built with Polymer with other custom elements, as well as built-in elements. The Polymer team has written collections of elements that you can use in your apps.
  • 27. Polymer Catalog (built in elements)
  • 28. Polymer Google Web Components closer look
  • 29. Use google-map element to show a simple map of Greece <!-- Polyfill Web Components support for older browsers --> <script src="components/webcomponentsjs/webcomponents-lite.min.js"></script> <!-- Import element --> <link rel="import" href="components/google-map/google-map.html"> <!-- Use element --> <google-map latitude="38.605225" longitude="24.645403"></google-map>
  • 30. Use google-map element adding some custom markers <google-map latitude="38.605225" longitude="24.645403" fit-to-markers> <google-map-marker latitude="37.969406" longitude="23.720744" title=" Hello Athens!"></google-map-marker> <google-map-marker latitude="39.104739" longitude="26.557254" title=" Hello Mitilini!"></google-map-marker> </google-map>
  • 31. Create a custom element with Polymer <dom-module id="user-element"> <style>...</style> <template> <img src="[[url]]" /> </template> <script> Polymer({ is: 'user-element', properties: { url: String } }); </script> </dom-module>
  • 32. Use our custom element <!-- Polyfill Web Components support for older browsers --> <script src="components/webcomponentsjs/webcomponents-lite.min.js"></script> <!-- Import element --> <link rel="import" href="components/user-element.html"> <!-- Use element --> <user-element url="http://someAvatar.com"></user-element>