SlideShare a Scribd company logo
WEBCOMPONENTS ARE YOUR
FRAMEWORKS BEST FRIEND
@filipbech
colibo.com
Webcomponents are your frameworks best friend
WRITE ONCE - USE
ANYWHERE
the promise of webcomponents
Webcomponents are your frameworks best friend
THIS TALK WILL BE
• Webcomponents - what and why
• How (basic tech intro)
• Using Webcomponents in your framework
• Your framework-component as a Web-component
WHY
• Interoperability - portability
• Native components brings us native performance
• Framework == implementation detail
Webcomponents are your frameworks best friend
ITS (FINALLY) HAPPENING…
SPECS
• custom elements
• shadow dom
• <template>
• es-modules
Webcomponents are your frameworks best friend
ATTRIBUTES VS PROPERTIES
Webcomponents are your frameworks best friend
Webcomponents are your frameworks best friend
CONTENT PROJECTION WITH SLOT
NAMED SLOTS
STYLING
• scoped to shadowRoot
• custom-properties
• special selectors - eg. :host, :slotted etc.
• ::parts on the horizon
WITH FRAMEWORKS
HOW TO USE FROM WITHIN FRAMEWORKS
• angular
• vue
• react (preact)
Webcomponents are your frameworks best friend
COMPARING FEATURE-COMPLETENESS
• The tests checks that a framework supports the usage of custom elements
• Each test has an associated weight, based on how critical it is. The final tally of
pass/fails is combined with these weights to create a weighted average score.
• Testing in browsers with native support AND in old browser with polyfill
• All credit goes to @rob_dodson
https://custom-elements-everywhere.com/
ANGULAR
Webcomponents are your frameworks best friend
Webcomponents are your frameworks best friend
https://custom-elements-everywhere.com/
VUE
Webcomponents are your frameworks best friend
https://custom-elements-everywhere.com/
REACT
Webcomponents are your frameworks best friend
https://custom-elements-everywhere.com/
Webcomponents are your frameworks best friend
REACT 17 MAYBE?
https://reactjs.org/blog/2017/09/08/dom-attributes-in-react-16.html
https://twitter.com/dan_abramov/status/1135440680375873536
https://github.com/facebook/react/issues/11347
PREACT TO THE RESCUE..?
https://custom-elements-everywhere.com/
Webcomponents are your frameworks best friend
SO…
• You can do it yourself
• Get a reference to the custom-element, and pass properties to it
• get a reference to the custom-element and addEventListener
YOUR COMPONENT
AS A CUSTOM-ELEMENT
the why, the how and all the details
WHY
• Interoperability
• Framework is an implementation detail
• The component-developer chooses their preferred tools
• Write a datepicker in React - use it in an Angular form
HOW
• Native Webcomponent framework
• Wrap in custom-element
WRAPPING
• Element-properties for data
• Dom-events for events
• Slots
• Style encapsulation w. shadowDOM
THE COMPARISON
• features
• css encapsulation
• slots
• properties (inputs)
• events (outputs)
• ease of use (for dev)
• size of bundle
• NOT framework integration (too hard to compare)
EXPORT TO WEBCOMPONENTS
• Angular (official)
• Vue (official)
• React (community)
WHAT ARE WE BUILDING
• a custom-button component
• takes a label as a property
• Has a Slot for content
• counts clicks
• emits a custom event (“action”) when clicked
• contains an h1, and styles applied to h1
Webcomponents are your frameworks best friend
@ANGULAR/ELEMENTS
Webcomponents are your frameworks best friend
Webcomponents are your frameworks best friend
Webcomponents are your frameworks best friend
Webcomponents are your frameworks best friend
NG-CONTENT OR <SLOT>
DISABLE NGZONE
RESULTS
ivy
ANGULAR 9 NEXT 16
IVY ELEMENTS
• Maybe with 9? Later?
• smaller, simpler, faster (~15kb)
• lazyNgElement
https://www.youtube.com/watch?v=JX5GGu_7JKc
@VUE/WEB-COMPONENT-
WRAPPER
Webcomponents are your frameworks best friend
Webcomponents are your frameworks best friend
Webcomponents are your frameworks best friend
Webcomponents are your frameworks best friend
BUILDING
WITH VUE
• feels elegant and light
• e.detail is an array of additional arguments to $emit()
• Doesn’t handle styles => points to css-modules as the solution
• The bundle is tiny - but requires a global vue (cannot be tree-shaken)
RESULTS
REACT
REACT IS DIFFERENT
• Passing callbacks as props instead of custom events
• CSS-in-JS
REACT…
• no official wrapper
• react-web-component
• web-react-components
• @adobe/react-webcomponent
• skateJS
WEB-REACT-COMPONENTS
• Looks like the real deal - but also not maintained
• Register()-method to wrap and register
• props.children is a <slot>
• Hack styles with <style dangerouslySetInnerHTML…>
• Requires the polyfill as it ships es5 😒
https://github.com/ChristophP/web-react-components
Webcomponents are your frameworks best friend
Webcomponents are your frameworks best friend
Webcomponents are your frameworks best friend
Webcomponents are your frameworks best friend
RESULTS
THE RESULTS ARE IN…
Angular Vue React
Consume 100 % 100 % 71 %
Wrap - features 😀 🙂 😕
Wrap - DX 🙂 🙂 😀
Wrap - bundlesize ~49kb ~36kb ~42kb
DO WE NEED FRAMEWORKS
can we use webcomponents alone?
USING WEBCOMPONENTS ALONE
• Sugar on top
• LitElement, Stencil, Svelte,
• Helpers below
• Utility-libraries for http, state-management, etc…
https://developers.google.com/web/fundamentals/web-components/best-practices
Webcomponents are your frameworks best friend
PLATFORM RESULTS
LitElement
Consume 100 %
All features 😀
Developer experience 😀
Wrap - bundlesize ~7kb
THE PLATFORM STILL HAVE SOME GAPS
• ::parts
• scoped registries
• import maps
• polyfilling is non-trivial
CONCLUSION
CONCLUSION
• Webcomponents and your framework complement each other.
• Doable today, but still a little complicated and some missing features
• Vue and Angular are good in using webcomponents. React not so much atm
• The wrappers are pretty cool, but incomplete, large and/or complex
(and no official wrapper for react)
• <slot>’s don’t mix/match so well with framework-features
• Lets make this happen…
https://github.com/filipbech/framework-webcomponents
THANK YOU!
This was “webcomponents are your frameworks best friend”
Im @filipbech
Follow for slides

More Related Content

PPT
Real World Rails Deployment
PDF
Web a Quebec - JS Debugging
PPTX
Agile sites @ telmore
PPTX
Agile sites2
PDF
Modern javascript
PDF
An Intense Overview of the React Ecosystem
PPTX
How NOT to get lost in the current JavaScript landscape
PDF
Flexible UI Components for a Multi-Framework World
Real World Rails Deployment
Web a Quebec - JS Debugging
Agile sites @ telmore
Agile sites2
Modern javascript
An Intense Overview of the React Ecosystem
How NOT to get lost in the current JavaScript landscape
Flexible UI Components for a Multi-Framework World

What's hot (20)

PDF
PLAT-8 Spring Web Scripts and Spring Surf
PPTX
Developing Complex WordPress Sites without Fear of Failure (with MVC)
PDF
Intro to React
PDF
Stencil the time for vanilla web components has arrived
PDF
React.js for Rails Developers
PDF
Azkaban-en
PDF
React on rails v6.1 at LA Ruby, November 2016
PDF
Michael North "Ember.js 2 - Future-friendly ambitious apps, that scale!"
PPTX
React101 v3
PDF
Write Once, Run Everywhere - Ember.js Munich
PDF
React.js - and how it changed our thinking about UI
PDF
Server Check.in case study - Drupal and Node.js
PDF
Hadoop Demystified + Automation Smackdown! Austin JUG June 24 2014
PDF
React server side rendering performance
PPTX
Do you queue
PPTX
SharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
PDF
User-percieved performance
ODP
Introduction to blogging with Jekyll
PPTX
[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS
PPTX
Jekyll, static websites generator
PLAT-8 Spring Web Scripts and Spring Surf
Developing Complex WordPress Sites without Fear of Failure (with MVC)
Intro to React
Stencil the time for vanilla web components has arrived
React.js for Rails Developers
Azkaban-en
React on rails v6.1 at LA Ruby, November 2016
Michael North "Ember.js 2 - Future-friendly ambitious apps, that scale!"
React101 v3
Write Once, Run Everywhere - Ember.js Munich
React.js - and how it changed our thinking about UI
Server Check.in case study - Drupal and Node.js
Hadoop Demystified + Automation Smackdown! Austin JUG June 24 2014
React server side rendering performance
Do you queue
SharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
User-percieved performance
Introduction to blogging with Jekyll
[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS
Jekyll, static websites generator
Ad

Similar to Webcomponents are your frameworks best friend (20)

PDF
Frameworks and webcomponents
PPTX
Introduction to web application development with Vue (for absolute beginners)...
PPTX
Lightning web components - Introduction, component Lifecycle, Events, decorat...
KEY
Single Page Applications - Desert Code Camp 2012
PPTX
SharePoint Saturday Twin Cities - SharePoint Framework, Angular & Azure Funct...
PPTX
European Collaboration Summit - SharePoint Framework Angular & Azure Functions
PPTX
SharePoint Saturday Vancouver - SharePoint Framework, Angular and Azure Funct...
PPTX
SharePoint Fest DC - SharePoint Framework, Angular and Azure Functions
PPTX
SharePoint Framework, Angular and Azure Functions
PDF
Escaping Test Hell - ACCU 2014
PPTX
Single Page Applications: Your Browser is the OS!
PPTX
JS Essence
PPTX
Lightning Web Component - LWC
PPTX
Deep dive into share point framework webparts
PPTX
TypeScript and Angular2 (Love at first sight)
PPTX
Introduction to React native
PDF
Masterin Large Scale Java Script Applications
PDF
Play Framework and Activator
KEY
Backbonification for dummies - Arrrrug 10/1/2012
KEY
Ship It ! with Ruby/ Rails Ecosystem
Frameworks and webcomponents
Introduction to web application development with Vue (for absolute beginners)...
Lightning web components - Introduction, component Lifecycle, Events, decorat...
Single Page Applications - Desert Code Camp 2012
SharePoint Saturday Twin Cities - SharePoint Framework, Angular & Azure Funct...
European Collaboration Summit - SharePoint Framework Angular & Azure Functions
SharePoint Saturday Vancouver - SharePoint Framework, Angular and Azure Funct...
SharePoint Fest DC - SharePoint Framework, Angular and Azure Functions
SharePoint Framework, Angular and Azure Functions
Escaping Test Hell - ACCU 2014
Single Page Applications: Your Browser is the OS!
JS Essence
Lightning Web Component - LWC
Deep dive into share point framework webparts
TypeScript and Angular2 (Love at first sight)
Introduction to React native
Masterin Large Scale Java Script Applications
Play Framework and Activator
Backbonification for dummies - Arrrrug 10/1/2012
Ship It ! with Ruby/ Rails Ecosystem
Ad

More from Filip Bruun Bech-Larsen (20)

PDF
Webcomponents from 0-100 - with Google's Lit
PDF
Content as a Service with Umbraco Headless
PDF
Whats next in clientside templating
PDF
Whats next in clientside templating
PDF
Angular ❤️ CMS from #AngularUp
PDF
Whats next in templating
PDF
The future of templating and frameworks
PDF
Whats next in templating
PDF
Future of the Web
PDF
Diversity at impact
PDF
Angular ❤️CMS
PDF
The Future of the web
PDF
Building a dynamic SPA website with Angular
PDF
Frontend development of the (current) future
PDF
Commerce and the browser in 2017
PPTX
Frontend State of the union
PPTX
AngularJS best practices
PPTX
Frontend development of the (current) future
PPTX
Dynamic content with Angular
PPTX
Observables - the why, what & how
Webcomponents from 0-100 - with Google's Lit
Content as a Service with Umbraco Headless
Whats next in clientside templating
Whats next in clientside templating
Angular ❤️ CMS from #AngularUp
Whats next in templating
The future of templating and frameworks
Whats next in templating
Future of the Web
Diversity at impact
Angular ❤️CMS
The Future of the web
Building a dynamic SPA website with Angular
Frontend development of the (current) future
Commerce and the browser in 2017
Frontend State of the union
AngularJS best practices
Frontend development of the (current) future
Dynamic content with Angular
Observables - the why, what & how

Recently uploaded (20)

PPTX
Tartificialntelligence_presentation.pptx
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Encapsulation theory and applications.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Machine Learning_overview_presentation.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PPTX
1. Introduction to Computer Programming.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
Tartificialntelligence_presentation.pptx
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Encapsulation theory and applications.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Empathic Computing: Creating Shared Understanding
Spectral efficient network and resource selection model in 5G networks
A comparative study of natural language inference in Swahili using monolingua...
Encapsulation_ Review paper, used for researhc scholars
Machine Learning_overview_presentation.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Unlocking AI with Model Context Protocol (MCP)
A comparative analysis of optical character recognition models for extracting...
Per capita expenditure prediction using model stacking based on satellite ima...
Group 1 Presentation -Planning and Decision Making .pptx
1. Introduction to Computer Programming.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Univ-Connecticut-ChatGPT-Presentaion.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Building Integrated photovoltaic BIPV_UPV.pdf

Webcomponents are your frameworks best friend