6. WHAT ARE WEB COMPONENTS?
Web Components is a suite of different
technologies allowing you to create
reusable custom elements — with their
functionality encapsulated away from
the rest of your code — and utilize them
in your web apps.
– MDN
〞
41. PROBLEM: FLASH OF UNSTYLED CONTENT (FOUC)
A flash of unstyled content is an
instance where a web page appears
briefly with the browser's default styles
prior to loading an external CSS
stylesheet, due to the web browser
engine rendering the page before all
information is retrieved
– Wikipedia
〞
43. PROBLEM: FLASH OF UNDEFINED CUSTOM
ELEMENTS (FOUCE)
You may see a brief flash of unstyled
HTML where your custom elements
should be when the page loads. This is
not dissimilar to FOUC, which occurs
when HTML is displayed before the
stylesheet has loaded.
– Cory LaViska
〞
47. WHY DOES FOUCE HAPPEN?
Browser requests HTML
It encounters an unknown element, "hello-world"
48. WHY DOES FOUCE HAPPEN?
Browser requests HTML
It encounters an unknown element, "hello-world"
The browser treats the unknown element as an inline element
No styles are applied due to the Shadow DOM boundary
49. WHY DOES FOUCE HAPPEN?
Browser requests HTML
It encounters an unknown element, "hello-world"
The browser treats the unknown element as an inline element
No styles are applied due to the Shadow DOM boundary
Browser loads the web components JavaScript
50. WHY DOES FOUCE HAPPEN?
Browser requests HTML
It encounters an unknown element, "hello-world"
The browser treats the unknown element as an inline element
No styles are applied due to the Shadow DOM boundary
Browser loads the web components JavaScript
The web component is instantiated, and the encapsulated
CSS & JavaScript is applied
FOUCE HAPPENS!!!
52. PROBLEM: SHADOW DOM DOESN'T PLAY WELL WITH
NATIVE FORMS
Custom elements cannot extend elements other than
HTMLElement*
53. PROBLEM: SHADOW DOM DOESN'T PLAY WELL WITH
NATIVE FORMS
Custom elements cannot extend elements other than
HTMLElement*
Form elements inside the Shadow DOM are not
considered as such by the component's parent form.
54. SHADOW DOM VS FORMS EXAMPLE
https://codepen.io/macdonst/embed/bGMLKBR?default-
tab=html%2Cresult&editable=true
55. INDEX
What are Web Components?
Why are they useful?
What are their problems?
How do we solve them?
71. 〞
We can't solve problems by using the
same kind of thinking we used when we
created them.
– Albert Einstein
72.
73. WHAT IS ENHANCE?
AUTHOR
Enhance allows developers to
write components as pure
functions that return HTML.
Then render them on the server
to deliver complete HTML
immediately available to the
end user.
Enhance takes care of the
tedious parts, allowing you to
use today’s Web Platform
standards more efficiently. As
new standards and platform
features become generally
available, Enhance will make
way for them.
STANDARDS
Enhance allows for easy
progressive enhancement so
that working HTML can be
further developed to add
additional functionality with
JavaScript.
PROGRESSIVE
Enhance is a web standards-based HTML framework. It’s
designed to provide a dependable foundation for building
lightweight, flexible, and future-proof web applications.
78. STOPPING FOUCE
Browser requests HTML
Enhance expands your custom elements on the server as well
as hoisting your encapsulated styles to the page's head tag
79. STOPPING FOUCE
Browser requests HTML
Enhance expands your custom elements on the server as well
as hoisting your encapsulated styles to the page's head tag
It encounters an unknown element, "hello-world"
80. STOPPING FOUCE
Browser requests HTML
Enhance expands your custom elements on the server as well
as hoisting your encapsulated styles to the page's head tag
It encounters an unknown element, "hello-world"
The browser treats the unknown element as an inline
element, but your CSS is already loaded, so it is styled
properly
81. STOPPING FOUCE
Browser requests HTML
Enhance expands your custom elements on the server as well
as hoisting your encapsulated styles to the page's head tag
It encounters an unknown element, "hello-world"
The browser treats the unknown element as an inline
element, but your CSS is already loaded, so it is styled
properly
Browser loads the web components JavaScript
82. STOPPING FOUCE
Browser requests HTML
Enhance expands your custom elements on the server as well
as hoisting your encapsulated styles to the page's head tag
It encounters an unknown element, "hello-world"
The browser treats the unknown element as an inline
element, but your CSS is already loaded, so it is styled
properly
Browser loads the web components JavaScript
The web component is instantiated, and your custom element
is "enhanced"
87. BENEFITS OF ENHANCE
All components are server side renderable
with no changes.
Leverage your CSS skills and style
encapsulation in the light DOM.
88. BENEFITS OF ENHANCE
All components are server side renderable
with no changes.
Leverage your CSS skills and style
encapsulation in the light DOM.
Use slots without the shadow DOM
89. BENEFITS OF ENHANCE
All components are server side renderable
with no changes.
Leverage your CSS skills and style
encapsulation in the light DOM.
Use slots without the shadow DOM
Avoid excessive JavaScript code by
leveraging the platform and web standards