A cheatsheet on creating web components by TJ Monserrat
Interactive Platforms for Learning
Web Components, Polymer, Web Performance, PWA
Avid web component user and creator
Search for the 50KB complex web-app
Reminder for the 2nd talk
Install Polymer-cli:
npm i -g polymer-cli
Web Components is a suite of different technologies allowing you to create reusable custom user interface components
— with their functionality encapsulated away from the rest of your code —
Web components are re-usable lego blocks that creates web-apps
Reusing code as much as possible is a good idea.
- MDN Web docs: Web Components
... the purpose of [information] hiding is to make inaccessible certain details that should not affect other parts of a system.
document.querySelector('#button-unique')
.addEventListener('click', handleClick)
The purpose of web components is to provide developers with the ability to create re-usable and encapsulated components...
Creation is encapsulated...
making creation re-usable...
Output is still exposed on accidental manipulation...
You cannot build a web component
without them...
Output is still exposed on accidental manipulation...
<this-is-my-element></this-is-my-element>
customElements.define('name-of-custom-element', CustomElementClass)this.attachShadow({mode: 'open'});
connectedCallback () { }
disconnectedCallback () { }
attributeChangedCallback () { }
static get observedAttributes() { }
But what if we want to track many attributes?
Or change attributes without using "setAttributes"
Or use some form of templating?
<link rel="import"> is only supported in Chrome (but polyfilled in other browsers)
bower is deprecated in favor of npm
You'll have to use the same Polymer.Element file on all polymer elements to avoid
dom-module conflicts
The race towards below 50KB web-app first-load