SlideShare a Scribd company logo
Stencil: The Time for Vanilla
Web Components has Arrived
Gil Fink
sparXys CEO, Working with Taboola
@gilfink / www.gilfink.net
Typical Application Web Page Design
From Design to Implementation
Main Section
Add your content
Campaign content
Controls
Component
Child component
Child component
Child component
<main-section />
<add-your-content />
<campaign-content />
<controls />
How would you build that
page?
Do we really need all these
frameworks/libraries?
What if we could teach the
browser new elements?
This is where our journey
begins
About Me
sparXys CEO and senior consultant
Microsoft MVP in the last 8 years
Pro Single Page Application Development (Apress) co-author
4 Microsoft Official Courses (MOCs) co-author
GDG Rishon and AngularUP co-organizer
Agenda
Web Components APIs in a nutshell
Getting to know Stencil
Web Components to the Rescue
Natively-supported, standardized JavaScript components
Some general goals:
Code Reuse Encapsulation
Separation of
Concerns
Composition Theming Expressive Semantic
The Web Components APIs
• Reusable DOM fragmentsTemplates
• Load HTML declarativelyImports
• DOM encapsulation
Shadow
DOM
• Create your own elements
Custom
Elements
Custom Element Example – Template
<template id="collapsibleTmpl">
<style>
#header {
background: blue;
color: white;
cursor: pointer;
padding: 2px;
}
</style>
<div style="border: black dashed 1px">
<div id="header"></div>
<slot name="slot-content"></slot>
</div>
</template>
Custom Element Example – Component
class CollapsiblePanel extends HTMLElement {
constructor() {
super();
this.init();
}
init() {
let shadowRoot = this.attachShadow({mode: 'open'});
const t = thisDoc.querySelector('#collapsibleTmpl');
const instance = t.content.cloneNode(true);
this.header = instance.querySelector('#header');
shadowRoot.appendChild(instance);
this.show = true;
this.boundCollapse = this.collapse.bind(this);
}
….
Custom Element Example – Component Cont.
connectedCallback() {
this.header.textContent = this.getAttribute('data-collapse-header');
this.header.addEventListener('click', this.boundCollapse);
this.content = this.querySelector("[slot='slot-content']");
}
disconnectedCallback() {
this.header.removeEventListener('click', this.boundCollapse);
}
collapse() {
this.show = !this.show;
this.content.style.display = this.show ? 'block' : 'none';
}
}
window.customElements.define('demo-collapsible', CollapsiblePanel);
Custom Element Example – Output
The demo can be found online in my github: http://github.com/gilf/
A Problem with Web Development Today
Catholic wedding with frameworks/libraries
• Infrastructure is based on a
framework/library
• Infrastructure isn’t reusable if other
company projects use another
framework/library
Problem with Web Development Today – Cont.
Custom Elements can remove the barrier of framework/library coupling
• Can be used by any framework/library
• Encapsulate their functionality and style
• Suitable to component infrastructure development
But there are problems with
custom components
Problems with Custom Elements
We are used to runtime framework/library goodies such as
• Virtual DOM
• Data binding
• Performance
• And etc.
Problems with Custom Elements – Cont.
Verbose syntax
• Too much boilerplate
• We need to craft everything
Problems with Custom Elements – Cont.
Still W3C working draft
Need Polyfills in some browsers
Is there a better way?
What if I told you that you
can solve the previous
problems in one place?
Stencil the time for vanilla web components has arrived
What is Stencil?
A compiler that generates Custom Elements
Not a framework/library
• Output is 100% standards-compliant web components
Adds powerful framework features to Web Components
• Virtual DOM
• Reactivity
• JSX
• TypeScript
• And etc.
Created and used heavily by Ionic Framework
Getting Started with Stencil
git clone https://github.com/ionic-team/stencil-component-starter.git my-
component
cd my-component
git remote rm origin
npm install
npm start
Stencil Component Example
import { Component, Prop } from '@stencil/core';
@Component({
tag: 'my-name',
styleUrl: 'my-name.scss'
})
export class MyName {
@Prop() name: string;
render() {
return (
<p>
Hello, my name is {this.name}
</p>
);
}
}
From Stencil to Custom Elements
import { Component, Prop } from
'@stencil/core';
@Component({
…
})
export class CollapsiblePanel {
…
}
Stencil Code JavaScript Code
Stencil
Compiler
var CollapsiblePanel = (function ()
{
function CollapsiblePanel() {
}
… // implementation
return CollapsiblePanel;
}());
Stencil
Compiler
Stencil the time for vanilla web components has arrived
Stencil Component Example
import {Component, Prop, State} from '@stencil/core';
@Component({
tag: 'collapsible-panel',
styleUrl: 'collapsible-panel.scss',
shadow: true
})
export class CollapsiblePanel {
@Prop() title: string;
@State() collapsed: boolean;
toggle() {
this.collapsed = !this.collapsed;
}
…
Stencil Component Example - Cont.
…
render() {
return (
<div>
<div id="header" onClick={this.toggle.bind(this)}>
<span>{this.title}</span>
</div>
<div id="content" hidden={this.collapsed}>
<slot />
</div>
</div>
);
}
}
Stencil Component Example – Output
The demo can be found online in my github: http://github.com/gilf/
Stencil Generated Component Advantages
Virtual DOM
• Fast DOM updates without common DOM performance pitfalls
Lazy Loading
• By default components load asynchronously and can be bundled with related
components
Reactivity
• Efficient updates based on property and state changes
High-performance Rendering
• Async rendering system, similar to React Fiber
How Stencil Solves the Frameworks Problem?
Stencil works primarily at build time
Any framework/library (such as React or Angular) can consume the
generated component
• As a script tag
• As a node module
• Using the stencil-starter-app
Stencil is suitable for infrastructure components
Summary
Web Components standard is very powerful
• But still in development
Stencil compiler can ease the pain of creating custom components
• Includes many advantages such as JSX, TypeScript and more
• Generates standard-compliant web components
Resources
Stencil website: https://stenciljs.com/
Custom Elements: https://developer.mozilla.org/en-
US/docs/Web/Web_Components/Custom_Elements
•Taboola – http://www.taboola.com – we are hiring!
•My Website – http://www.gilfink.net
•Follow me on Twitter – @gilfink
#UseThePlatform
Thank You!
Ask me questions at Taboola booth ☺
Ad

More Related Content

What's hot (20)

Introduction to jQuery - College Lecture
Introduction to jQuery - College LectureIntroduction to jQuery - College Lecture
Introduction to jQuery - College Lecture
Zac Gordon
 
Developing Complex WordPress Sites without Fear of Failure (with MVC)
Developing Complex WordPress Sites without Fear of Failure (with MVC)Developing Complex WordPress Sites without Fear of Failure (with MVC)
Developing Complex WordPress Sites without Fear of Failure (with MVC)
Mike Schinkel
 
Write Once, Run Everywhere
Write Once, Run EverywhereWrite Once, Run Everywhere
Write Once, Run Everywhere
Mike North
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
Jumping Bean
 
So, you want to be a plugin developer?
So, you want to be a plugin developer?So, you want to be a plugin developer?
So, you want to be a plugin developer?
ylefebvre
 
Wordcamp Toronto Presentation
Wordcamp Toronto PresentationWordcamp Toronto Presentation
Wordcamp Toronto Presentation
Roy Sivan
 
SharePoint Development 101
SharePoint Development 101SharePoint Development 101
SharePoint Development 101
Greg Hurlman
 
One language to rule them all type script
One language to rule them all type scriptOne language to rule them all type script
One language to rule them all type script
Gil Fink
 
Rails Concept
Rails ConceptRails Concept
Rails Concept
Javed Hussain
 
Introduction to Web Components & Polymer Workshop - JS Interactive
Introduction to Web Components & Polymer Workshop - JS InteractiveIntroduction to Web Components & Polymer Workshop - JS Interactive
Introduction to Web Components & Polymer Workshop - JS Interactive
John Riviello
 
The WordPress REST API as a Springboard for Website Greatness
The WordPress REST API as a Springboard for Website GreatnessThe WordPress REST API as a Springboard for Website Greatness
The WordPress REST API as a Springboard for Website Greatness
WP Engine UK
 
WordPress and Client Side Web Applications WCTO
WordPress and Client Side Web Applications WCTOWordPress and Client Side Web Applications WCTO
WordPress and Client Side Web Applications WCTO
Roy Sivan
 
The Tale of 2 CLIs - Ember-cli and Angular-cli
The Tale of 2 CLIs - Ember-cli and Angular-cliThe Tale of 2 CLIs - Ember-cli and Angular-cli
The Tale of 2 CLIs - Ember-cli and Angular-cli
Tracy Lee
 
WHAT IS HTML5?(20100510)
WHAT IS HTML5?(20100510)WHAT IS HTML5?(20100510)
WHAT IS HTML5?(20100510)
Shumpei Shiraishi
 
Functional testing your Grails app with GEB
Functional testing your Grails app with GEBFunctional testing your Grails app with GEB
Functional testing your Grails app with GEB
GR8Conf
 
ASP.NET 5 Overview: Post RTM
ASP.NET 5 Overview: Post RTMASP.NET 5 Overview: Post RTM
ASP.NET 5 Overview: Post RTM
Shahed Chowdhuri
 
GraphQL IndyJS April 2016
GraphQL IndyJS April 2016GraphQL IndyJS April 2016
GraphQL IndyJS April 2016
Brad Pillow
 
Getting started with angular js
Getting started with angular jsGetting started with angular js
Getting started with angular js
Maurice De Beijer [MVP]
 
ASP.NET MVC From The Ground Up
ASP.NET MVC From The Ground UpASP.NET MVC From The Ground Up
ASP.NET MVC From The Ground Up
Kevin Griffin
 
EuroPython 2011 - How to build complex web applications having fun?
EuroPython 2011 - How to build complex web applications having fun?EuroPython 2011 - How to build complex web applications having fun?
EuroPython 2011 - How to build complex web applications having fun?
Andrew Mleczko
 
Introduction to jQuery - College Lecture
Introduction to jQuery - College LectureIntroduction to jQuery - College Lecture
Introduction to jQuery - College Lecture
Zac Gordon
 
Developing Complex WordPress Sites without Fear of Failure (with MVC)
Developing Complex WordPress Sites without Fear of Failure (with MVC)Developing Complex WordPress Sites without Fear of Failure (with MVC)
Developing Complex WordPress Sites without Fear of Failure (with MVC)
Mike Schinkel
 
Write Once, Run Everywhere
Write Once, Run EverywhereWrite Once, Run Everywhere
Write Once, Run Everywhere
Mike North
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
Jumping Bean
 
So, you want to be a plugin developer?
So, you want to be a plugin developer?So, you want to be a plugin developer?
So, you want to be a plugin developer?
ylefebvre
 
Wordcamp Toronto Presentation
Wordcamp Toronto PresentationWordcamp Toronto Presentation
Wordcamp Toronto Presentation
Roy Sivan
 
SharePoint Development 101
SharePoint Development 101SharePoint Development 101
SharePoint Development 101
Greg Hurlman
 
One language to rule them all type script
One language to rule them all type scriptOne language to rule them all type script
One language to rule them all type script
Gil Fink
 
Introduction to Web Components & Polymer Workshop - JS Interactive
Introduction to Web Components & Polymer Workshop - JS InteractiveIntroduction to Web Components & Polymer Workshop - JS Interactive
Introduction to Web Components & Polymer Workshop - JS Interactive
John Riviello
 
The WordPress REST API as a Springboard for Website Greatness
The WordPress REST API as a Springboard for Website GreatnessThe WordPress REST API as a Springboard for Website Greatness
The WordPress REST API as a Springboard for Website Greatness
WP Engine UK
 
WordPress and Client Side Web Applications WCTO
WordPress and Client Side Web Applications WCTOWordPress and Client Side Web Applications WCTO
WordPress and Client Side Web Applications WCTO
Roy Sivan
 
The Tale of 2 CLIs - Ember-cli and Angular-cli
The Tale of 2 CLIs - Ember-cli and Angular-cliThe Tale of 2 CLIs - Ember-cli and Angular-cli
The Tale of 2 CLIs - Ember-cli and Angular-cli
Tracy Lee
 
Functional testing your Grails app with GEB
Functional testing your Grails app with GEBFunctional testing your Grails app with GEB
Functional testing your Grails app with GEB
GR8Conf
 
ASP.NET 5 Overview: Post RTM
ASP.NET 5 Overview: Post RTMASP.NET 5 Overview: Post RTM
ASP.NET 5 Overview: Post RTM
Shahed Chowdhuri
 
GraphQL IndyJS April 2016
GraphQL IndyJS April 2016GraphQL IndyJS April 2016
GraphQL IndyJS April 2016
Brad Pillow
 
ASP.NET MVC From The Ground Up
ASP.NET MVC From The Ground UpASP.NET MVC From The Ground Up
ASP.NET MVC From The Ground Up
Kevin Griffin
 
EuroPython 2011 - How to build complex web applications having fun?
EuroPython 2011 - How to build complex web applications having fun?EuroPython 2011 - How to build complex web applications having fun?
EuroPython 2011 - How to build complex web applications having fun?
Andrew Mleczko
 

Similar to Stencil the time for vanilla web components has arrived (20)

Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
Gil Fink
 
Stencil: The Time for Vanilla Web Components has Arrived
Stencil: The Time for Vanilla Web Components has ArrivedStencil: The Time for Vanilla Web Components has Arrived
Stencil: The Time for Vanilla Web Components has Arrived
Gil Fink
 
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
Felix Arntz
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
Mike Wilcox
 
Turku loves-storybook-styleguidist-styled-components
Turku loves-storybook-styleguidist-styled-componentsTurku loves-storybook-styleguidist-styled-components
Turku loves-storybook-styleguidist-styled-components
James Stone
 
Challenges of angular in production (Tasos Bekos) - GreeceJS #17
Challenges of angular in production (Tasos Bekos) - GreeceJS #17Challenges of angular in production (Tasos Bekos) - GreeceJS #17
Challenges of angular in production (Tasos Bekos) - GreeceJS #17
GreeceJS
 
«Разрушаем Вавилонскую Башню WWW с помощью веб-компонент»​
«Разрушаем Вавилонскую Башню WWW с помощью веб-компонент»​«Разрушаем Вавилонскую Башню WWW с помощью веб-компонент»​
«Разрушаем Вавилонскую Башню WWW с помощью веб-компонент»​
FDConf
 
Front-end tower of Babylon
Front-end tower of BabylonFront-end tower of Babylon
Front-end tower of Babylon
Denis Radin
 
Web component driven development
Web component driven developmentWeb component driven development
Web component driven development
Gil Fink
 
An Introduction to Web Components
An Introduction to Web ComponentsAn Introduction to Web Components
An Introduction to Web Components
Red Pill Now
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
GDSC UofT Mississauga
 
Writing an extensible web testing framework ready for the cloud slide share
Writing an extensible web testing framework ready for the cloud   slide shareWriting an extensible web testing framework ready for the cloud   slide share
Writing an extensible web testing framework ready for the cloud slide share
Mike Ensor
 
Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016
Marco Breveglieri
 
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
 
Full Stack_Reac web Development and Application
Full Stack_Reac web Development and ApplicationFull Stack_Reac web Development and Application
Full Stack_Reac web Development and Application
Jeyarajs7
 
Front End Development for Back End Developers - Devoxx UK 2017
 Front End Development for Back End Developers - Devoxx UK 2017 Front End Development for Back End Developers - Devoxx UK 2017
Front End Development for Back End Developers - Devoxx UK 2017
Matt Raible
 
Instagram filters (8 24)
Instagram filters (8 24)Instagram filters (8 24)
Instagram filters (8 24)
Ivy Rueb
 
Implementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing CompanyImplementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing Company
Marcos Labad
 
Sitecore development approach evolution – destination helix
Sitecore development approach evolution – destination helixSitecore development approach evolution – destination helix
Sitecore development approach evolution – destination helix
Peter Nazarov
 
Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!
Doris Chen
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
Gil Fink
 
Stencil: The Time for Vanilla Web Components has Arrived
Stencil: The Time for Vanilla Web Components has ArrivedStencil: The Time for Vanilla Web Components has Arrived
Stencil: The Time for Vanilla Web Components has Arrived
Gil Fink
 
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
Felix Arntz
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
Mike Wilcox
 
Turku loves-storybook-styleguidist-styled-components
Turku loves-storybook-styleguidist-styled-componentsTurku loves-storybook-styleguidist-styled-components
Turku loves-storybook-styleguidist-styled-components
James Stone
 
Challenges of angular in production (Tasos Bekos) - GreeceJS #17
Challenges of angular in production (Tasos Bekos) - GreeceJS #17Challenges of angular in production (Tasos Bekos) - GreeceJS #17
Challenges of angular in production (Tasos Bekos) - GreeceJS #17
GreeceJS
 
«Разрушаем Вавилонскую Башню WWW с помощью веб-компонент»​
«Разрушаем Вавилонскую Башню WWW с помощью веб-компонент»​«Разрушаем Вавилонскую Башню WWW с помощью веб-компонент»​
«Разрушаем Вавилонскую Башню WWW с помощью веб-компонент»​
FDConf
 
Front-end tower of Babylon
Front-end tower of BabylonFront-end tower of Babylon
Front-end tower of Babylon
Denis Radin
 
Web component driven development
Web component driven developmentWeb component driven development
Web component driven development
Gil Fink
 
An Introduction to Web Components
An Introduction to Web ComponentsAn Introduction to Web Components
An Introduction to Web Components
Red Pill Now
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
GDSC UofT Mississauga
 
Writing an extensible web testing framework ready for the cloud slide share
Writing an extensible web testing framework ready for the cloud   slide shareWriting an extensible web testing framework ready for the cloud   slide share
Writing an extensible web testing framework ready for the cloud slide share
Mike Ensor
 
Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016
Marco Breveglieri
 
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
 
Full Stack_Reac web Development and Application
Full Stack_Reac web Development and ApplicationFull Stack_Reac web Development and Application
Full Stack_Reac web Development and Application
Jeyarajs7
 
Front End Development for Back End Developers - Devoxx UK 2017
 Front End Development for Back End Developers - Devoxx UK 2017 Front End Development for Back End Developers - Devoxx UK 2017
Front End Development for Back End Developers - Devoxx UK 2017
Matt Raible
 
Instagram filters (8 24)
Instagram filters (8 24)Instagram filters (8 24)
Instagram filters (8 24)
Ivy Rueb
 
Implementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing CompanyImplementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing Company
Marcos Labad
 
Sitecore development approach evolution – destination helix
Sitecore development approach evolution – destination helixSitecore development approach evolution – destination helix
Sitecore development approach evolution – destination helix
Peter Nazarov
 
Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!
Doris Chen
 
Ad

More from Gil Fink (20)

Becoming a Tech Speaker
Becoming a Tech SpeakerBecoming a Tech Speaker
Becoming a Tech Speaker
Gil Fink
 
Web animation on steroids web animation api
Web animation on steroids web animation api Web animation on steroids web animation api
Web animation on steroids web animation api
Gil Fink
 
The Time for Vanilla Web Components has Arrived
The Time for Vanilla Web Components has ArrivedThe Time for Vanilla Web Components has Arrived
The Time for Vanilla Web Components has Arrived
Gil Fink
 
Being a tech speaker
Being a tech speakerBeing a tech speaker
Being a tech speaker
Gil Fink
 
Working with Data in Service Workers
Working with Data in Service WorkersWorking with Data in Service Workers
Working with Data in Service Workers
Gil Fink
 
Demystifying Angular Animations
Demystifying Angular AnimationsDemystifying Angular Animations
Demystifying Angular Animations
Gil Fink
 
Redux data flow with angular
Redux data flow with angularRedux data flow with angular
Redux data flow with angular
Gil Fink
 
Redux data flow with angular
Redux data flow with angularRedux data flow with angular
Redux data flow with angular
Gil Fink
 
Who's afraid of front end databases?
Who's afraid of front end databases?Who's afraid of front end databases?
Who's afraid of front end databases?
Gil Fink
 
One language to rule them all type script
One language to rule them all type scriptOne language to rule them all type script
One language to rule them all type script
Gil Fink
 
End to-end apps with type script
End to-end apps with type scriptEnd to-end apps with type script
End to-end apps with type script
Gil Fink
 
Web components
Web componentsWeb components
Web components
Gil Fink
 
Redux data flow with angular 2
Redux data flow with angular 2Redux data flow with angular 2
Redux data flow with angular 2
Gil Fink
 
Biological Modeling, Powered by AngularJS
Biological Modeling, Powered by AngularJSBiological Modeling, Powered by AngularJS
Biological Modeling, Powered by AngularJS
Gil Fink
 
Who's afraid of front end databases
Who's afraid of front end databasesWho's afraid of front end databases
Who's afraid of front end databases
Gil Fink
 
Biological modeling, powered by angular js
Biological modeling, powered by angular jsBiological modeling, powered by angular js
Biological modeling, powered by angular js
Gil Fink
 
Web components the future is here
Web components   the future is hereWeb components   the future is here
Web components the future is here
Gil Fink
 
Whos afraid of front end databases?
Whos afraid of front end databases?Whos afraid of front end databases?
Whos afraid of front end databases?
Gil Fink
 
Web Components - The Future is Here
Web Components - The Future is HereWeb Components - The Future is Here
Web Components - The Future is Here
Gil Fink
 
Getting Started with TypeScript
Getting Started with TypeScriptGetting Started with TypeScript
Getting Started with TypeScript
Gil Fink
 
Becoming a Tech Speaker
Becoming a Tech SpeakerBecoming a Tech Speaker
Becoming a Tech Speaker
Gil Fink
 
Web animation on steroids web animation api
Web animation on steroids web animation api Web animation on steroids web animation api
Web animation on steroids web animation api
Gil Fink
 
The Time for Vanilla Web Components has Arrived
The Time for Vanilla Web Components has ArrivedThe Time for Vanilla Web Components has Arrived
The Time for Vanilla Web Components has Arrived
Gil Fink
 
Being a tech speaker
Being a tech speakerBeing a tech speaker
Being a tech speaker
Gil Fink
 
Working with Data in Service Workers
Working with Data in Service WorkersWorking with Data in Service Workers
Working with Data in Service Workers
Gil Fink
 
Demystifying Angular Animations
Demystifying Angular AnimationsDemystifying Angular Animations
Demystifying Angular Animations
Gil Fink
 
Redux data flow with angular
Redux data flow with angularRedux data flow with angular
Redux data flow with angular
Gil Fink
 
Redux data flow with angular
Redux data flow with angularRedux data flow with angular
Redux data flow with angular
Gil Fink
 
Who's afraid of front end databases?
Who's afraid of front end databases?Who's afraid of front end databases?
Who's afraid of front end databases?
Gil Fink
 
One language to rule them all type script
One language to rule them all type scriptOne language to rule them all type script
One language to rule them all type script
Gil Fink
 
End to-end apps with type script
End to-end apps with type scriptEnd to-end apps with type script
End to-end apps with type script
Gil Fink
 
Web components
Web componentsWeb components
Web components
Gil Fink
 
Redux data flow with angular 2
Redux data flow with angular 2Redux data flow with angular 2
Redux data flow with angular 2
Gil Fink
 
Biological Modeling, Powered by AngularJS
Biological Modeling, Powered by AngularJSBiological Modeling, Powered by AngularJS
Biological Modeling, Powered by AngularJS
Gil Fink
 
Who's afraid of front end databases
Who's afraid of front end databasesWho's afraid of front end databases
Who's afraid of front end databases
Gil Fink
 
Biological modeling, powered by angular js
Biological modeling, powered by angular jsBiological modeling, powered by angular js
Biological modeling, powered by angular js
Gil Fink
 
Web components the future is here
Web components   the future is hereWeb components   the future is here
Web components the future is here
Gil Fink
 
Whos afraid of front end databases?
Whos afraid of front end databases?Whos afraid of front end databases?
Whos afraid of front end databases?
Gil Fink
 
Web Components - The Future is Here
Web Components - The Future is HereWeb Components - The Future is Here
Web Components - The Future is Here
Gil Fink
 
Getting Started with TypeScript
Getting Started with TypeScriptGetting Started with TypeScript
Getting Started with TypeScript
Gil Fink
 
Ad

Recently uploaded (20)

Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
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
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
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.
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
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
 
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
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
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
 
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
 
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
 
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
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
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
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
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
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
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
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
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.
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
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
 
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
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
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
 
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
 
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
 
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
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
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
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
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
 

Stencil the time for vanilla web components has arrived

  • 1. Stencil: The Time for Vanilla Web Components has Arrived Gil Fink sparXys CEO, Working with Taboola @gilfink / www.gilfink.net
  • 3. From Design to Implementation Main Section Add your content Campaign content Controls Component Child component Child component Child component <main-section /> <add-your-content /> <campaign-content /> <controls />
  • 4. How would you build that page?
  • 5. Do we really need all these frameworks/libraries?
  • 6. What if we could teach the browser new elements?
  • 7. This is where our journey begins
  • 8. About Me sparXys CEO and senior consultant Microsoft MVP in the last 8 years Pro Single Page Application Development (Apress) co-author 4 Microsoft Official Courses (MOCs) co-author GDG Rishon and AngularUP co-organizer
  • 9. Agenda Web Components APIs in a nutshell Getting to know Stencil
  • 10. Web Components to the Rescue Natively-supported, standardized JavaScript components Some general goals: Code Reuse Encapsulation Separation of Concerns Composition Theming Expressive Semantic
  • 11. The Web Components APIs • Reusable DOM fragmentsTemplates • Load HTML declarativelyImports • DOM encapsulation Shadow DOM • Create your own elements Custom Elements
  • 12. Custom Element Example – Template <template id="collapsibleTmpl"> <style> #header { background: blue; color: white; cursor: pointer; padding: 2px; } </style> <div style="border: black dashed 1px"> <div id="header"></div> <slot name="slot-content"></slot> </div> </template>
  • 13. Custom Element Example – Component class CollapsiblePanel extends HTMLElement { constructor() { super(); this.init(); } init() { let shadowRoot = this.attachShadow({mode: 'open'}); const t = thisDoc.querySelector('#collapsibleTmpl'); const instance = t.content.cloneNode(true); this.header = instance.querySelector('#header'); shadowRoot.appendChild(instance); this.show = true; this.boundCollapse = this.collapse.bind(this); } ….
  • 14. Custom Element Example – Component Cont. connectedCallback() { this.header.textContent = this.getAttribute('data-collapse-header'); this.header.addEventListener('click', this.boundCollapse); this.content = this.querySelector("[slot='slot-content']"); } disconnectedCallback() { this.header.removeEventListener('click', this.boundCollapse); } collapse() { this.show = !this.show; this.content.style.display = this.show ? 'block' : 'none'; } } window.customElements.define('demo-collapsible', CollapsiblePanel);
  • 15. Custom Element Example – Output The demo can be found online in my github: http://github.com/gilf/
  • 16. A Problem with Web Development Today Catholic wedding with frameworks/libraries • Infrastructure is based on a framework/library • Infrastructure isn’t reusable if other company projects use another framework/library
  • 17. Problem with Web Development Today – Cont. Custom Elements can remove the barrier of framework/library coupling • Can be used by any framework/library • Encapsulate their functionality and style • Suitable to component infrastructure development
  • 18. But there are problems with custom components
  • 19. Problems with Custom Elements We are used to runtime framework/library goodies such as • Virtual DOM • Data binding • Performance • And etc.
  • 20. Problems with Custom Elements – Cont. Verbose syntax • Too much boilerplate • We need to craft everything
  • 21. Problems with Custom Elements – Cont. Still W3C working draft Need Polyfills in some browsers
  • 22. Is there a better way?
  • 23. What if I told you that you can solve the previous problems in one place?
  • 25. What is Stencil? A compiler that generates Custom Elements Not a framework/library • Output is 100% standards-compliant web components Adds powerful framework features to Web Components • Virtual DOM • Reactivity • JSX • TypeScript • And etc. Created and used heavily by Ionic Framework
  • 26. Getting Started with Stencil git clone https://github.com/ionic-team/stencil-component-starter.git my- component cd my-component git remote rm origin npm install npm start
  • 27. Stencil Component Example import { Component, Prop } from '@stencil/core'; @Component({ tag: 'my-name', styleUrl: 'my-name.scss' }) export class MyName { @Prop() name: string; render() { return ( <p> Hello, my name is {this.name} </p> ); } }
  • 28. From Stencil to Custom Elements import { Component, Prop } from '@stencil/core'; @Component({ … }) export class CollapsiblePanel { … } Stencil Code JavaScript Code Stencil Compiler var CollapsiblePanel = (function () { function CollapsiblePanel() { } … // implementation return CollapsiblePanel; }()); Stencil Compiler
  • 30. Stencil Component Example import {Component, Prop, State} from '@stencil/core'; @Component({ tag: 'collapsible-panel', styleUrl: 'collapsible-panel.scss', shadow: true }) export class CollapsiblePanel { @Prop() title: string; @State() collapsed: boolean; toggle() { this.collapsed = !this.collapsed; } …
  • 31. Stencil Component Example - Cont. … render() { return ( <div> <div id="header" onClick={this.toggle.bind(this)}> <span>{this.title}</span> </div> <div id="content" hidden={this.collapsed}> <slot /> </div> </div> ); } }
  • 32. Stencil Component Example – Output The demo can be found online in my github: http://github.com/gilf/
  • 33. Stencil Generated Component Advantages Virtual DOM • Fast DOM updates without common DOM performance pitfalls Lazy Loading • By default components load asynchronously and can be bundled with related components Reactivity • Efficient updates based on property and state changes High-performance Rendering • Async rendering system, similar to React Fiber
  • 34. How Stencil Solves the Frameworks Problem? Stencil works primarily at build time Any framework/library (such as React or Angular) can consume the generated component • As a script tag • As a node module • Using the stencil-starter-app Stencil is suitable for infrastructure components
  • 35. Summary Web Components standard is very powerful • But still in development Stencil compiler can ease the pain of creating custom components • Includes many advantages such as JSX, TypeScript and more • Generates standard-compliant web components
  • 36. Resources Stencil website: https://stenciljs.com/ Custom Elements: https://developer.mozilla.org/en- US/docs/Web/Web_Components/Custom_Elements •Taboola – http://www.taboola.com – we are hiring! •My Website – http://www.gilfink.net •Follow me on Twitter – @gilfink
  • 38. Thank You! Ask me questions at Taboola booth ☺