Flaws of the Web Components in
2019 and how to address them
Vladlen Fedosov, Director of R&D @Namecheap, Inc
Hint: prepare your QR code scanners 😉
Vlad Fedosov
Director of R&D @Namecheap
TL;DR:
● 10 years in the industry
● Went path from Junior to Architect
● Use JS since Mootools era
● Amateur DevOps evangelist
● AWS ninja
● Believe in self-organized, cross-functional teams
“Opening the door for everyone to
a free and open Internet”
Our use case & concerns
● Browser support
● Frameworks compatibility
● SSR + SEO
● Styling
● Accessibility
● Versioning
● Delivery
● Solution of choice
● Integration path
Web Components
Quick refresh of the subject
Web Components – In the nutshell
Web components is a set of web platform APIs that allow you to create new
custom, reusable, encapsulated HTML tags to use in web pages and web apps.
Custom components and widgets build on the Web Component standards, will
work across modern browsers, and can be used with any JavaScript library or
framework that works with HTML.
Core specifications: Custom Elements, Shadow DOM
Important note: you may opt out Shadow DOM and stick to the
Custom Elements only.
Attention – WCs can be used in production
All major frameworks that exist nowadays fully support Web Components (only React has
are some issues with advanced integration).
Browser support:
● IE 10–11 and Edge (Chakra based) are out of the game as they do not support Shadow
DOM.
● All other browsers (Chrome, FF, Safari, iOS, Android, considering 2 latest versions) work
just fine with all major techs we need.
Mobile: Ionic 4 heavily uses Web Components
But they’re still not perfect
Let’s go through the main issues you may face and ways to handle them
Growth problems
Growth problems – Young ecosystem
Web Components as a standard is under development during last several years.
And it was changed quite drastically in V1 (comparing to V0). Also the adoption
just recently grown to acceptable point. And so the tools are rapidly evolving and
changing. Let’s looks at the most relevant examples:
● Stencil – 1.0 version released few months ago, under active development,
documentation need to be improved, relatively low adoption
● LitElement – was started just ~1 year ago, under active development, just
recently published their roadmap.
● React support is far from being perfect
Growth problems – Browser support
Every major browser has open Web Components related issues nowadays. Some
of them major some of them don’t. But be ready to learn most of them at some
point.
The best browser to run them is Chrome, surprise, surprise 😅
Growth problems – Coming specs
As time comes HTML Imports spec was removed while Shadow DOM and Custom
Elements specs were evolved from V0 to V1. And I expect to see new
specifications being adopted as there are still gaps (which we’ll discuss later) in
the architecture. Let’s look at the examples I like:
● Declarative Shadow DOM
● CSS Modules V1
● Scoped Custom Element Registries
● CSS Shadow Parts
CSS inside Shadow DOM
Shadow DOM - brief introduction
CSS inside Shadow DOM – How to load it?
CSS defined inside shadow DOM is scoped to it. Style rules don't leak out and
page styles don't bleed in. But how should I load styles for my markup? Two
options here:
● Constructible Stylesheets (Chrome only, future spec)
● Loading via <link> or <style> tag (performance hit)
CSS inside Shadow DOM – Performance hit
Time, ms
CSS inside Shadow DOM – Performance hit
Devices count
Time, ms
CSS inside Shadow DOM – Way to load it now
● Include only CSS your component really need (extra CSS causes
performance issues)
● Keep WCs related CSS inside JS bundle to prevent FOUC
● How to inject CSS:
1. If available: Use Constructible Stylesheets, for Chrome users (~70% of desktop
users)
2. If Firefox: Use <link> with CSS Blob (Until Mozilla will fix this issue)
3. Else: Use inline CSS via <style> tag (Webkit has optimization for this)
Server Side Rendering
Server Side Rendering (SSR)
It’s theoretically possible to fully render WC at server side (and it even works for
simple ones), but...
There is no stable implementation yet, as well as way to represent Shadow DOM
in HTML 😟 But guys are actively working on a solution.
So what should we do then…? 🤯
Server Side Rendering (SSR) - YAGNI
YAGNI! Keep your content in Light DOM, put WC related code to client bundle and
communicate via DOM attributes/props/events. Treat your WCs as native HTML elements.
You can agree that you’re not rendering Shadow DOM for example for <input
type="text"> element. If components are well designed, crawlers do not need a flattened
tree to get text contents. And use ARIA attributes to add semantic meaning to your custom
elements
<good-components>hello world</good-components>
// It’s shadow tree is using a slot to get text contents
<bad-components></bad-components>
// "hello world" is hard-coded in its shadow tree.
Server Side Rendering (SSR) - YAGNI
<x-tab-group aria-label="My test tabs">
<x-tab role="tab" slot="tab">Title for tab 1</x-tab>
<x-tab-panel role="tabpanel" slot="panel">Content 1</x-tab-panel>
<x-tab role="tab" slot="tab">Title for tab 2</x-tab>
<x-tab-panel role="tabpanel" slot="panel">Content 2</x-tab-panel>
<x-tab role="tab" slot="tab">Title for tab 3</x-tab>
<x-tab-panel role="tabpanel" slot="panel">Content 3</x-tab-panel>
</x-tab-group>
Server Side Rendering (SSR) - Experimental way
But if you really want somehow render your web components, try to experiment with
prerendering (medium complexity) or real server side rendering (hard complexity).
But keep in mind that serialization (including Shadow DOM) and hydration is up to you to
implement. Also server side Web API implementation needed for SSR.
Take a look at the Stencil and SkateJS implementation (scan QR codes).
Versioning
Versioning – What’s wrong with it?
Currently (and it will likely remain) all WCs must be registered in global registry. So
you can’t have 2 versions of the same component on a single page. This follows
approach that Browser use for the DOM, you have single version of it at a time.
This may become an issue if you have multiple teams working on different apps at
the same website (microservices at frontend pattern).
Versioning – Options we have
Let’s look at the options we have here:
1. Never do breaking changes. This is the principle that Browsers use. And while it’s
possible to do it and it even may be the best option to start with, it’s obvious that it
contradicts to the principle “fail fast, fail safe” and doesn’t facilitate innovations.
2. Tag based versioning. So instead of having <x-button> you would have
<x-button-v1> to accommodate further major versions. So if Microservice 1 requires
button@1.1.5 and Microservice 2 requires button@1.2.1 – button@1.2.1 only will
be used. And if MS1 needs v1.1.5 and MS2 needs 2.0 – both components will be
registered.
3. Microservice based scoping. So instead of having <x-button>
you would have <x-button-mymicroservice>
Summing up… 🤯
Our use case & concerns
● Browser support 🙂 (good)
● Frameworks compatibility 😀 (very good)
● SSR + SEO 🧐 (non trivial, needs verification)
● Styling 😅(good, but can be better)
● Accessibility 😀 (very good)
● Versioning 🙃 (tricky)
● Delivery 😎 (no major changes)
● Solution of choice 😜 (your choice, try LitElement first)
● Integration path 😜 (your choice)
Bonus point
Don’t try to get rid of your favourite framework
Web Components vs Frameworks
To be short: they’re different. Don’t try to replace good old frameworks like Vue.js
or React with Web Components.
Use cases for Web Components:
● Design System / Pattern library implementation
○ Especially valuable if you have to deal with multiple frameworks or want it to be
used by your B2B clients.
● Use them internally to build next-gen framework 😅
○ Like Google did with AMP and Ionic made Stencil
● Bring our own use case 🙋‍♂
Thank you for coming,
you rock 🔥 🤘
Vlad Fedosov
Director of R&D
@Namecheap, Inc
vlad.fedosov@gmail.com
Slides:
Or just scan it: Related
article:
bit.ly/2lYh8eB
bit.ly/2mRZCJa

More Related Content

PPT
Making Your Site Look Great in IE7
PDF
AngularJS + React
PPTX
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
PDF
Introduction to angular js july 6th 2014
PDF
JSFest 2019: Technology agnostic microservices at SPA frontend
PDF
Magento 2 Design Patterns
PPTX
3-TIER ARCHITECTURE IN ASP.NET MVC
PDF
Magento 2 Seminar - Daniel Genis - Magento 2 benchmarks
Making Your Site Look Great in IE7
AngularJS + React
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
Introduction to angular js july 6th 2014
JSFest 2019: Technology agnostic microservices at SPA frontend
Magento 2 Design Patterns
3-TIER ARCHITECTURE IN ASP.NET MVC
Magento 2 Seminar - Daniel Genis - Magento 2 benchmarks

What's hot (20)

PDF
Modern Web Application Development Workflow - EclipseCon Europe 2014
PDF
Implementing Web Services In Java
PDF
Web components the future is here
PDF
How To Create Theme in Magento 2 - Part 1
PDF
Angular 2 interview questions and answers
PPTX
Magento 2 Theme Trainning for Beginners | Magenest
PDF
How to create theme in Magento 2 - Part 2
PDF
A Work Day Of A Web Developer
PPTX
JavaScript DOM - Dynamic interactive Code
PPT
Getting started with angular js
PPTX
Monster JavaScript Course - 50+ projects and applications
PPTX
Web matrix part 2
PPT
Introduction to HTML5
PPTX
Vuejs getting-started - Extended Version
PPTX
SharePoint Web part programming
PPTX
PDF
Kickstarting Node.js Projects with Yeoman
PDF
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
PPTX
Introduction to html 5
PPTX
AngularJS 2.0
Modern Web Application Development Workflow - EclipseCon Europe 2014
Implementing Web Services In Java
Web components the future is here
How To Create Theme in Magento 2 - Part 1
Angular 2 interview questions and answers
Magento 2 Theme Trainning for Beginners | Magenest
How to create theme in Magento 2 - Part 2
A Work Day Of A Web Developer
JavaScript DOM - Dynamic interactive Code
Getting started with angular js
Monster JavaScript Course - 50+ projects and applications
Web matrix part 2
Introduction to HTML5
Vuejs getting-started - Extended Version
SharePoint Web part programming
Kickstarting Node.js Projects with Yeoman
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
Introduction to html 5
AngularJS 2.0
Ad

Similar to KharkivJS: Flaws of the Web Components in 2019 and how to address them (20)

PDF
LvivCSS: Web Components as a foundation for Design System
PDF
Building Web Applications Without a Framework
PPT
Reaching for the Future with Web Components and Polymer
PPTX
MongoDB.local Atlanta: MongoDB Stitch Tutorial
PPT
Mobile Monday Presentation: Responsive Web Design
PPTX
Web Components
PPTX
MongoDB.local Seattle 2019: MongoDB Stitch Tutorial
PPT
Welcome to IE8 - Integrating Your Site With Internet Explorer 8
PPTX
Web Performance: 3 Stages to Success
PDF
The Superhero’s Method of Modern HTML5 Development by RapidValue Solutions
PDF
ReactJS vs AngularJS - Head to Head comparison
PDF
Frontend Performance: Illusions & browser rendering
PPTX
MongoDB.local Dallas 2019: MongoDB Stitch Tutorial
ODP
Html5
PPTX
Building high performing web pages
PDF
SMX_DevTools_Monaco_2.pdf
PPT
Is it time to start using HTML 5
PDF
How to write an application and not roll down to 1 fps
PDF
Angular 1.x reloaded: improve your app now! and get ready for 2.0
PDF
LvivCSS: Web Components as a foundation for Design System
Building Web Applications Without a Framework
Reaching for the Future with Web Components and Polymer
MongoDB.local Atlanta: MongoDB Stitch Tutorial
Mobile Monday Presentation: Responsive Web Design
Web Components
MongoDB.local Seattle 2019: MongoDB Stitch Tutorial
Welcome to IE8 - Integrating Your Site With Internet Explorer 8
Web Performance: 3 Stages to Success
The Superhero’s Method of Modern HTML5 Development by RapidValue Solutions
ReactJS vs AngularJS - Head to Head comparison
Frontend Performance: Illusions & browser rendering
MongoDB.local Dallas 2019: MongoDB Stitch Tutorial
Html5
Building high performing web pages
SMX_DevTools_Monaco_2.pdf
Is it time to start using HTML 5
How to write an application and not roll down to 1 fps
Angular 1.x reloaded: improve your app now! and get ready for 2.0
Ad

Recently uploaded (20)

PPTX
Rise of the Digital Control Grid Zeee Media and Hope and Tivon FTWProject.com
PPTX
Introduction-to-Artificial-Intelligence (1).pptx
PDF
Altius execution marketplace concept.pdf
PDF
【AI論文解説】高速・高品質な生成を実現するFlow Map Models(Part 1~3)
PPTX
From XAI to XEE through Influence and Provenance.Controlling model fairness o...
PDF
Intravenous drug administration application for pediatric patients via augmen...
PDF
TrustArc Webinar - Data Minimization in Practice_ Reducing Risk, Enhancing Co...
PDF
EGCB_Solar_Project_Presentation_and Finalcial Analysis.pdf
PDF
Secure Java Applications against Quantum Threats
PPTX
maintenance powerrpoint for adaprive and preventive
PDF
Optimizing bioinformatics applications: a novel approach with human protein d...
PDF
Rooftops detection with YOLOv8 from aerial imagery and a brief review on roof...
PDF
Decision Optimization - From Theory to Practice
PDF
Ebook - The Future of AI A Comprehensive Guide.pdf
PPTX
From Curiosity to ROI — Cost-Benefit Analysis of Agentic Automation [3/6]
PDF
Human Computer Interaction Miterm Lesson
PDF
Domain-specific knowledge and context in large language models: challenges, c...
PDF
“Introduction to Designing with AI Agents,” a Presentation from Amazon Web Se...
PPTX
Slides World Game (s) Great Redesign Eco Economic Epochs.pptx
PDF
Examining Bias in AI Generated News Content.pdf
Rise of the Digital Control Grid Zeee Media and Hope and Tivon FTWProject.com
Introduction-to-Artificial-Intelligence (1).pptx
Altius execution marketplace concept.pdf
【AI論文解説】高速・高品質な生成を実現するFlow Map Models(Part 1~3)
From XAI to XEE through Influence and Provenance.Controlling model fairness o...
Intravenous drug administration application for pediatric patients via augmen...
TrustArc Webinar - Data Minimization in Practice_ Reducing Risk, Enhancing Co...
EGCB_Solar_Project_Presentation_and Finalcial Analysis.pdf
Secure Java Applications against Quantum Threats
maintenance powerrpoint for adaprive and preventive
Optimizing bioinformatics applications: a novel approach with human protein d...
Rooftops detection with YOLOv8 from aerial imagery and a brief review on roof...
Decision Optimization - From Theory to Practice
Ebook - The Future of AI A Comprehensive Guide.pdf
From Curiosity to ROI — Cost-Benefit Analysis of Agentic Automation [3/6]
Human Computer Interaction Miterm Lesson
Domain-specific knowledge and context in large language models: challenges, c...
“Introduction to Designing with AI Agents,” a Presentation from Amazon Web Se...
Slides World Game (s) Great Redesign Eco Economic Epochs.pptx
Examining Bias in AI Generated News Content.pdf

KharkivJS: Flaws of the Web Components in 2019 and how to address them

  • 1. Flaws of the Web Components in 2019 and how to address them Vladlen Fedosov, Director of R&D @Namecheap, Inc Hint: prepare your QR code scanners 😉
  • 2. Vlad Fedosov Director of R&D @Namecheap TL;DR: ● 10 years in the industry ● Went path from Junior to Architect ● Use JS since Mootools era ● Amateur DevOps evangelist ● AWS ninja ● Believe in self-organized, cross-functional teams
  • 3. “Opening the door for everyone to a free and open Internet”
  • 4. Our use case & concerns ● Browser support ● Frameworks compatibility ● SSR + SEO ● Styling ● Accessibility ● Versioning ● Delivery ● Solution of choice ● Integration path
  • 6. Web Components – In the nutshell Web components is a set of web platform APIs that allow you to create new custom, reusable, encapsulated HTML tags to use in web pages and web apps. Custom components and widgets build on the Web Component standards, will work across modern browsers, and can be used with any JavaScript library or framework that works with HTML. Core specifications: Custom Elements, Shadow DOM Important note: you may opt out Shadow DOM and stick to the Custom Elements only.
  • 7. Attention – WCs can be used in production All major frameworks that exist nowadays fully support Web Components (only React has are some issues with advanced integration). Browser support: ● IE 10–11 and Edge (Chakra based) are out of the game as they do not support Shadow DOM. ● All other browsers (Chrome, FF, Safari, iOS, Android, considering 2 latest versions) work just fine with all major techs we need. Mobile: Ionic 4 heavily uses Web Components
  • 8. But they’re still not perfect Let’s go through the main issues you may face and ways to handle them
  • 10. Growth problems – Young ecosystem Web Components as a standard is under development during last several years. And it was changed quite drastically in V1 (comparing to V0). Also the adoption just recently grown to acceptable point. And so the tools are rapidly evolving and changing. Let’s looks at the most relevant examples: ● Stencil – 1.0 version released few months ago, under active development, documentation need to be improved, relatively low adoption ● LitElement – was started just ~1 year ago, under active development, just recently published their roadmap. ● React support is far from being perfect
  • 11. Growth problems – Browser support Every major browser has open Web Components related issues nowadays. Some of them major some of them don’t. But be ready to learn most of them at some point. The best browser to run them is Chrome, surprise, surprise 😅
  • 12. Growth problems – Coming specs As time comes HTML Imports spec was removed while Shadow DOM and Custom Elements specs were evolved from V0 to V1. And I expect to see new specifications being adopted as there are still gaps (which we’ll discuss later) in the architecture. Let’s look at the examples I like: ● Declarative Shadow DOM ● CSS Modules V1 ● Scoped Custom Element Registries ● CSS Shadow Parts
  • 14. Shadow DOM - brief introduction
  • 15. CSS inside Shadow DOM – How to load it? CSS defined inside shadow DOM is scoped to it. Style rules don't leak out and page styles don't bleed in. But how should I load styles for my markup? Two options here: ● Constructible Stylesheets (Chrome only, future spec) ● Loading via <link> or <style> tag (performance hit)
  • 16. CSS inside Shadow DOM – Performance hit Time, ms
  • 17. CSS inside Shadow DOM – Performance hit Devices count Time, ms
  • 18. CSS inside Shadow DOM – Way to load it now ● Include only CSS your component really need (extra CSS causes performance issues) ● Keep WCs related CSS inside JS bundle to prevent FOUC ● How to inject CSS: 1. If available: Use Constructible Stylesheets, for Chrome users (~70% of desktop users) 2. If Firefox: Use <link> with CSS Blob (Until Mozilla will fix this issue) 3. Else: Use inline CSS via <style> tag (Webkit has optimization for this)
  • 20. Server Side Rendering (SSR) It’s theoretically possible to fully render WC at server side (and it even works for simple ones), but... There is no stable implementation yet, as well as way to represent Shadow DOM in HTML 😟 But guys are actively working on a solution. So what should we do then…? 🤯
  • 21. Server Side Rendering (SSR) - YAGNI YAGNI! Keep your content in Light DOM, put WC related code to client bundle and communicate via DOM attributes/props/events. Treat your WCs as native HTML elements. You can agree that you’re not rendering Shadow DOM for example for <input type="text"> element. If components are well designed, crawlers do not need a flattened tree to get text contents. And use ARIA attributes to add semantic meaning to your custom elements <good-components>hello world</good-components> // It’s shadow tree is using a slot to get text contents <bad-components></bad-components> // "hello world" is hard-coded in its shadow tree.
  • 22. Server Side Rendering (SSR) - YAGNI <x-tab-group aria-label="My test tabs"> <x-tab role="tab" slot="tab">Title for tab 1</x-tab> <x-tab-panel role="tabpanel" slot="panel">Content 1</x-tab-panel> <x-tab role="tab" slot="tab">Title for tab 2</x-tab> <x-tab-panel role="tabpanel" slot="panel">Content 2</x-tab-panel> <x-tab role="tab" slot="tab">Title for tab 3</x-tab> <x-tab-panel role="tabpanel" slot="panel">Content 3</x-tab-panel> </x-tab-group>
  • 23. Server Side Rendering (SSR) - Experimental way But if you really want somehow render your web components, try to experiment with prerendering (medium complexity) or real server side rendering (hard complexity). But keep in mind that serialization (including Shadow DOM) and hydration is up to you to implement. Also server side Web API implementation needed for SSR. Take a look at the Stencil and SkateJS implementation (scan QR codes).
  • 25. Versioning – What’s wrong with it? Currently (and it will likely remain) all WCs must be registered in global registry. So you can’t have 2 versions of the same component on a single page. This follows approach that Browser use for the DOM, you have single version of it at a time. This may become an issue if you have multiple teams working on different apps at the same website (microservices at frontend pattern).
  • 26. Versioning – Options we have Let’s look at the options we have here: 1. Never do breaking changes. This is the principle that Browsers use. And while it’s possible to do it and it even may be the best option to start with, it’s obvious that it contradicts to the principle “fail fast, fail safe” and doesn’t facilitate innovations. 2. Tag based versioning. So instead of having <x-button> you would have <x-button-v1> to accommodate further major versions. So if Microservice 1 requires [email protected] and Microservice 2 requires [email protected][email protected] only will be used. And if MS1 needs v1.1.5 and MS2 needs 2.0 – both components will be registered. 3. Microservice based scoping. So instead of having <x-button> you would have <x-button-mymicroservice>
  • 28. Our use case & concerns ● Browser support 🙂 (good) ● Frameworks compatibility 😀 (very good) ● SSR + SEO 🧐 (non trivial, needs verification) ● Styling 😅(good, but can be better) ● Accessibility 😀 (very good) ● Versioning 🙃 (tricky) ● Delivery 😎 (no major changes) ● Solution of choice 😜 (your choice, try LitElement first) ● Integration path 😜 (your choice)
  • 29. Bonus point Don’t try to get rid of your favourite framework
  • 30. Web Components vs Frameworks To be short: they’re different. Don’t try to replace good old frameworks like Vue.js or React with Web Components. Use cases for Web Components: ● Design System / Pattern library implementation ○ Especially valuable if you have to deal with multiple frameworks or want it to be used by your B2B clients. ● Use them internally to build next-gen framework 😅 ○ Like Google did with AMP and Ionic made Stencil ● Bring our own use case 🙋‍♂
  • 31. Thank you for coming, you rock 🔥 🤘
  • 32. Vlad Fedosov Director of R&D @Namecheap, Inc [email protected] Slides: Or just scan it: Related article: bit.ly/2lYh8eB bit.ly/2mRZCJa