SlideShare a Scribd company logo
Building framework agnostic
UI with Web Components
Piotr Nalepa @ Auto1 Polska | 4Developers Katowice 2019
@sunpietro
https://blog.piotrnalepa.pl
Building framework agnostic UI with Web Components
Piotr Nalepa
● Senior Software Engineer @ Auto1 Polska
● Blogger
● Football fan
2
Building framework agnostic UI with Web Components
The story
3
Building framework agnostic UI with Web Components
Many different projects
with similar UI
4
Building framework agnostic UI with Web Components 5
Building framework agnostic UI with Web Components
Many different ways
to keep UI similar
6
Building framework agnostic UI with Web Components 7
Bootstrap, Foundation, other
Building framework agnostic UI with Web Components
Challenges with existing tools
8
Building framework agnostic UI with Web Components
UI development challenges
9
Building framework agnostic UI with Web Components
It’s difficult
10
Building framework agnostic UI with Web Components
Design consistency
11
Building framework agnostic UI with Web Components
Likely work duplication
12
Building framework agnostic UI with Web Components
What does agnostic mean?
13
Building framework agnostic UI with Web Components
● Not using any specialized tools, like frameworks
● Making software working everywhere
no matter the platform
14
Building framework agnostic UI with Web Components 15
Framework agnostic UI
Building framework agnostic UI with Web Components 16
Design consistency
Building framework agnostic UI with Web Components
Development time reduction
17
Building framework agnostic UI with Web Components
Code reusability
18
Building framework agnostic UI with Web Components
As less dependencies as possible
needed
19
Building framework agnostic UI with Web Components
But it still sounds like
definition of Bootstrap, right?
20
Building framework agnostic UI with Web Components
Web Components
21
Building framework agnostic UI with Web Components
● Templates
● Shadow DOM
● Custom Elements
● Modules
22
Building framework agnostic UI with Web Components
Why Web Components?
23
Building framework agnostic UI with Web Components
Browser native technology
24
Building framework agnostic UI with Web Components
Decent support in modern
browsers
25
Building framework agnostic UI with Web Components 26
Building framework agnostic UI with Web Components
UI element as HTML tag
27
Building framework agnostic UI with Web Components 28
Building framework agnostic UI with Web Components
SSR support
29
Building framework agnostic UI with Web Components
Simple to use
30
Building framework agnostic UI with Web Components 31
Building framework agnostic UI with Web Components 32
When debugging
Building framework agnostic UI with Web Components 33
Building framework agnostic UI with Web Components 34
Scoping
Building framework agnostic UI with Web Components
Creating reusable
Web Components
35
Building framework agnostic UI with Web Components 36Building framework agnostic UI with Web Components
Building framework agnostic UI with Web Components 37
Web Component lifecycle
Building framework agnostic UI with Web Components 38
constructor()
Building framework agnostic UI with Web Components 39
Building framework agnostic UI with Web Components
connectedCallback()
40
Building framework agnostic UI with Web Components 41
Building framework agnostic UI with Web Components
disconnectedCallback()
42
Building framework agnostic UI with Web Components 43
Building framework agnostic UI with Web Components
attributeChangedCallback()
44
Building framework agnostic UI with Web Components 45
Building framework agnostic UI with Web Components
adoptedCallback()
46
Building framework agnostic UI with Web Components 47
Including web component
Building framework agnostic UI with Web Components
Web Component in action
48
Building framework agnostic UI with Web Components
Web Components
+
JS frameworks/libraries
49
Building framework agnostic UI with Web Components
It’s possible!
50
Building framework agnostic UI with Web Components
Custom Elements + React
51
Building framework agnostic UI with Web Components 52
Building framework agnostic UI with Web Components 53
Just like native
Building framework agnostic UI with Web Components
Custom Elements + VueJS
54
Building framework agnostic UI with Web Components 55
Building framework agnostic UI with Web Components
Custom Elements + Angular
56
Building framework agnostic UI with Web Components
Requires more effort
57
Building framework agnostic UI with Web Components 58
Angular module definition
Building framework agnostic UI with Web Components 59
Angular CLI config - angular.json
the config property path:
projects.<project-name>.architect.build.options.scripts
Building framework agnostic UI with Web Components
Using Web Component in component
60
Building framework agnostic UI with Web Components 61
In case of supporting older browsers
Use polyfills
https://www.webcomponents.org/polyfills
Building framework agnostic UI with Web Components
Web Components frameworks
● LitHTML
● Stencil
● SkateJS
● other
62
Building framework agnostic UI with Web Components
Web Components
+
Micro Frontends
63
Building framework agnostic UI with Web Components
Micro Frontends architecture
64
Building framework agnostic UI with Web Components 65
Building framework agnostic UI with Web Components
App per
feature
66
Building framework agnostic UI with Web Components
Feature
ownership
67
Building framework agnostic UI with Web Components
Independency
68
Building framework agnostic UI with Web Components
Micro Frontends pros
69
Building framework agnostic UI with Web Components
Simplified web development
70
Building framework agnostic UI with Web Components
Self-contained code
71
Building framework agnostic UI with Web Components
Faster and independent web
development
72
Building framework agnostic UI with Web Components
Autonomous teams
73
Building framework agnostic UI with Web Components
Micro Frontends cons
74
Building framework agnostic UI with Web Components
Not proper for small projects
75
Building framework agnostic UI with Web Components
Payload size
76
Building framework agnostic UI with Web Components
Environment differences vel.
outdated project
77
Building framework agnostic UI with Web Components
Micro Frontends + Web
Components. Good to go?
78
Building framework agnostic UI with Web Components
It depends
79
Building framework agnostic UI with Web Components
Takeaways
80
Building framework agnostic UI with Web Components
Avoid UI code duplication
81
Building framework agnostic UI with Web Components
Think about UI consistency
82
Building framework agnostic UI with Web Components
Save your time
83
Building framework agnostic UI with Web Components
Follow the checklist
https://github.com/webcomponents/gold-standard/wiki
84
Building framework agnostic UI with Web Components
Companies can hire developers
from different domains
85
Building framework agnostic UI with Web Components
Where you can find me?
Blog: https://blog.piotrnalepa.pl
Twitter: https://twitter.com/sunpietro
Github: https://github.com/sunpietro
86
Building framework agnostic UI with Web Components
Slides will be posted on Twitter
87
Building framework agnostic UI with Web Components
Thank you!
88

More Related Content

PPTX
Azure active directory
PPTX
Power bi overview
PDF
Elastic Observability
PDF
Adf presentation
PPTX
AWS Lake Formation Deep Dive
PDF
Cloud Security Governance
PPTX
Microsoft Azure - Introduction
PPTX
Looker Studio Data Contracts - Data.Monks.pptx
Azure active directory
Power bi overview
Elastic Observability
Adf presentation
AWS Lake Formation Deep Dive
Cloud Security Governance
Microsoft Azure - Introduction
Looker Studio Data Contracts - Data.Monks.pptx

What's hot (20)

PDF
Microservices Workshop - Craft Conference
PPTX
Data Center Migration to the AWS Cloud
PPTX
Continuous Data Ingestion pipeline for the Enterprise
KEY
Event Driven Architecture
PDF
Migrate to Microsoft Azure with Confidence
PPTX
Logic Apps and Azure Functions
PPTX
Introduction to the Microsoft Azure Cloud.pptx
PDF
apidays Paris 2022 - Agile API delivery with Feature Toggles, Rafik Ferroukh,...
PDF
Achieving observability-in-modern-applications
PPTX
Introduction to Data Engineering
PPT
Introduction to jira
PDF
Building a Semantic Layer of your Data Platform
PPSX
Containers Docker Kind Kubernetes Istio
PPTX
REST API debate: OData vs GraphQL vs ORDS
PPTX
DW Migration Webinar-March 2022.pptx
PDF
UiPath - IT Automation (1).pdf
PDF
Customer Event Hub - the modern Customer 360° view
PPTX
SRE 101 (Site Reliability Engineering)
PDF
Introduction To Jira
PDF
Graph based data models
Microservices Workshop - Craft Conference
Data Center Migration to the AWS Cloud
Continuous Data Ingestion pipeline for the Enterprise
Event Driven Architecture
Migrate to Microsoft Azure with Confidence
Logic Apps and Azure Functions
Introduction to the Microsoft Azure Cloud.pptx
apidays Paris 2022 - Agile API delivery with Feature Toggles, Rafik Ferroukh,...
Achieving observability-in-modern-applications
Introduction to Data Engineering
Introduction to jira
Building a Semantic Layer of your Data Platform
Containers Docker Kind Kubernetes Istio
REST API debate: OData vs GraphQL vs ORDS
DW Migration Webinar-March 2022.pptx
UiPath - IT Automation (1).pdf
Customer Event Hub - the modern Customer 360° view
SRE 101 (Site Reliability Engineering)
Introduction To Jira
Graph based data models
Ad

Similar to Building Framework Agnostic UI with Web Components (20)

PDF
The future is hybrid
PDF
Front End Development for Back End Developers - vJUG24 2017
PDF
Beginner's Guide to Frontend Development: Comparing Angular, React, Ember, an...
PDF
Building Enterprise Grade Front-End Applications with JavaScript Frameworks
PDF
Desktop apps with node webkit
PPTX
Engineering Frontends
PPTX
Universal Applications with Universal JavaScript
PDF
Building Cross-Platform Mobile Apps
PDF
2016 stop writing javascript frameworks by Joe Gregorio
PDF
AngularJS in Production (CTO Forum)
PDF
The Frontend Developer Landscape Explained and the Rise of Advanced Frontend ...
PDF
LvivCSS: Web Components as a foundation for Design System
PPTX
Stencil JS for Framework Free Web Components | Steven Zelek
KEY
Palm Developer Day PhoneGap
PPTX
Isomorphic JavaScript – future of the web
PPT
Intro to SPA using JavaScript & ASP.NET
KEY
Future of Mobile
PDF
Html5 Apps
PDF
HTML5 Can't Do That
PDF
Quasar Framework: Full Front-end Stack for Developing SPA, SSR, Mobile and De...
The future is hybrid
Front End Development for Back End Developers - vJUG24 2017
Beginner's Guide to Frontend Development: Comparing Angular, React, Ember, an...
Building Enterprise Grade Front-End Applications with JavaScript Frameworks
Desktop apps with node webkit
Engineering Frontends
Universal Applications with Universal JavaScript
Building Cross-Platform Mobile Apps
2016 stop writing javascript frameworks by Joe Gregorio
AngularJS in Production (CTO Forum)
The Frontend Developer Landscape Explained and the Rise of Advanced Frontend ...
LvivCSS: Web Components as a foundation for Design System
Stencil JS for Framework Free Web Components | Steven Zelek
Palm Developer Day PhoneGap
Isomorphic JavaScript – future of the web
Intro to SPA using JavaScript & ASP.NET
Future of Mobile
Html5 Apps
HTML5 Can't Do That
Quasar Framework: Full Front-end Stack for Developing SPA, SSR, Mobile and De...
Ad

More from Piotr Nalepa (7)

PPTX
Extending eZ Platform 2.x with Symfony and React
PPTX
Extending Studio
PPTX
JAK TESTOWAĆ CZYSTY KOD JAVASCRIPT?
PDF
Developing native-like Windows application using JavaScript, SSE, eZ Platform...
PPTX
Perfomance w Joomla - Jak przyspieszyć działanie strony?
PPTX
ZOSTAŃ NINJA JOOMLA! DEVELOPEREM Automatyzacja zadań w procesie tworzenia sza...
PDF
Semantyka w tworzeniu stron www prezentacja
Extending eZ Platform 2.x with Symfony and React
Extending Studio
JAK TESTOWAĆ CZYSTY KOD JAVASCRIPT?
Developing native-like Windows application using JavaScript, SSE, eZ Platform...
Perfomance w Joomla - Jak przyspieszyć działanie strony?
ZOSTAŃ NINJA JOOMLA! DEVELOPEREM Automatyzacja zadań w procesie tworzenia sza...
Semantyka w tworzeniu stron www prezentacja

Recently uploaded (20)

PDF
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
PDF
Paper PDF World Game (s) Great Redesign.pdf
PPTX
Internet___Basics___Styled_ presentation
PDF
Introduction to the IoT system, how the IoT system works
PDF
WebRTC in SignalWire - troubleshooting media negotiation
PPTX
Power Point - Lesson 3_2.pptx grad school presentation
PPTX
522797556-Unit-2-Temperature-measurement-1-1.pptx
PDF
Unit-1 introduction to cyber security discuss about how to secure a system
PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
PPTX
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
PDF
The New Creative Director: How AI Tools for Social Media Content Creation Are...
PDF
Decoding a Decade: 10 Years of Applied CTI Discipline
PDF
Sims 4 Historia para lo sims 4 para jugar
PDF
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
PPTX
Introduction to Information and Communication Technology
PDF
Cloud-Scale Log Monitoring _ Datadog.pdf
PPTX
Job_Card_System_Styled_lorem_ipsum_.pptx
PDF
An introduction to the IFRS (ISSB) Stndards.pdf
PPTX
Module 1 - Cyber Law and Ethics 101.pptx
PPT
isotopes_sddsadsaadasdasdasdasdsa1213.ppt
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
Paper PDF World Game (s) Great Redesign.pdf
Internet___Basics___Styled_ presentation
Introduction to the IoT system, how the IoT system works
WebRTC in SignalWire - troubleshooting media negotiation
Power Point - Lesson 3_2.pptx grad school presentation
522797556-Unit-2-Temperature-measurement-1-1.pptx
Unit-1 introduction to cyber security discuss about how to secure a system
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
The New Creative Director: How AI Tools for Social Media Content Creation Are...
Decoding a Decade: 10 Years of Applied CTI Discipline
Sims 4 Historia para lo sims 4 para jugar
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
Introduction to Information and Communication Technology
Cloud-Scale Log Monitoring _ Datadog.pdf
Job_Card_System_Styled_lorem_ipsum_.pptx
An introduction to the IFRS (ISSB) Stndards.pdf
Module 1 - Cyber Law and Ethics 101.pptx
isotopes_sddsadsaadasdasdasdasdsa1213.ppt

Building Framework Agnostic UI with Web Components

Editor's Notes

  • #2: Hi everyone! My name is Piotr Nalepa and I’m really happy to speak here in front of such prominent group of fellow devs. Today I’m going to talk about building reusable user interfaces with Web Components. Before I start my speech I have a couple of questions to you: How many of you already know Web Components? How many of you actually tried to build some kind of UI or app with Web Components?
  • #3: Let me introduce myself. Who am I? I’m a Senior Software Engineer at Auto1 Polska. We’re building the online marketplace for efficient buying and selling of inspected used cars. In short, it’s a platform for selling used cars. Apart from that, I’m also a blogger. I have my own blog which contains a lot of articles I’ve written since 2009. Quite long time, isn’t it? There you can read about CSS, JavaScript, even some PHP and bash stuff (old times). On my blog I’m sharing my knowledge regarding web development. I recommend to check it after this presentation. You’ll see the URL at the end of this slideshow presentation. In my free time, I enjoy watching and playing football a lot. I’m playing as a goalkeeper in futsal, because I’m not scared being hit hard by the ball ;)
  • #4: Have you ever needed to build UI and reuse it in multiple projects? This is very common situation nowadays and there are many tools that can help to achieve that, for instance Bootstrap or Foundation. I bet you know them. Things like Bootstrap help to build user interfaces rapidly, but there are some caveats of using it: you have to be sure the CSS is loaded correctly. What does it mean? It means the styles have to be loaded in a correct order and they cannot interfere with your custom CSS styles in an unexpected way, like rules overriding. you have to be sure that the HTML code is implemented correctly, and you have to be sure JS is applied correctly to Bootstrap elements. These 3 things complicates development a bit. Have you ever been in situation that you implemented some Bootstrap code like in examples and it didn’t work? That’s what I’m talking about. In terms of UI build with Web Components there is one more win. You’re building UI that uses only native JS features, so they can be easily reused across many different projects, no matter the JS framework you’re using or if you’re using just vanilla JS.
  • #7: Having many projects that accomodate similar UI sometimes make it difficult to stick with one selected library because of the project requirements or designs require something slightly different, but crucial from UI perspective, that haven’t been implemented in one library, but it might exists in another one. Oftentimes you might want to create your own, custom UI part of web app or website, but it leads to reinventing the wheel.
  • #8: There are many UI libraries on the market. Among them Bootstrap and Foundation are ones of the most popular libraries. There was a time in the past that if you looked on the website design you already knew what tool it was built with. Now it had changed of course.
  • #9: From my point of view the biggest challenge is to implement correct code samples in the correct way. By this I mean, implementing it inthe way it doesn’t force you to drop initial ideas for your UI, because a component from selected UI library is not flexible enough as you thought before.
  • #11: Building universal UI elements that can be reused in many places, in many different projects is difficult. The main difficulty is to build elements that are flexible enough when implementing and cover most of the use cases.
  • #12: Creating custom elements that look the same way no matter the project is another challenge. At the begining it’s easy to keep everything looking consistent. The problem begins after a longer time of development, when new requirements come. In such cases it’s extremely important to avoid making UI parts working only in some specific use cases and thinking you’ll fix it later. It’s also challenging to think about a possible use cases that have to be covered with a specific UI feature. Personally I believe that covering most of possible use cases at the beginning will pay off in the future, even if it take a bit more time to deliver a functionality.
  • #13: As I mentioned it earlier, developers tend to reinvent the wheel with any new project. Smart developers see patterns and try to extract them as a kind of library for the future usage.
  • #15: In the context of IT
  • #17: Allows you to keep design consistency across the projects
  • #18: There’s no need for extra code development.
  • #19: Having already existing UI elements library makes it less time-consuming to use them.
  • #20: Becuase of using browser-native features
  • #29: Thre’s a biggest win and a difference from Bootstrap like libraries
  • #35: Another big win
  • #37: On this slide you can a code sample that is used to generate some basic custom element. I’m going to explain you in details in the next slides.
  • #65: In this approach, the web application is broken down into its features, and each feature is owned, frontend to backend, by a different team. This ensures that every feature is developed, tested and deployed independently from other features
  • #66: An approach to developing web application as a composition of small frontend apps. Instead of writing a large monolith frontend application, the application is broken down into domain specific micro frontends, which are self-contained and can be developed and deployed independently.
  • #68: Each team owns a feature. It means,they can decide what tools to use in order to deliver a specific set of functionalities
  • #69: Each feature app can be developed and deployed independently from other apps.
  • #71: Each team should be able to choose and upgrade their stack without having to coordinate with other teams. Custom Elements are a great way to hide implementation details while providing a neutral interface to others.
  • #72: Isolate Team Code Don’t share a runtime, even if all teams use the same framework. Build independent apps that are self contained. Don’t rely on shared state or global variables.
  • #73: Independent deployment Just as with microservices, independent deployability of micro frontends is key. This reduces the scope of any given deployment, which in turn reduces the associated risk. Regardless of how or where your frontend code is hosted, each micro frontend should have its own continuous delivery pipeline, which builds, tests and deploys it all the way to production. We should be able to deploy each micro frontend with very little thought given to the current state of other codebases or pipelines. It shouldn't matter if the old monolith is on a fixed, manual, quarterly release cycle, or if the team next door has pushed a half-finished or broken feature into their master branch. If a given micro frontend is ready to go to production, it should be able to do so, and that decision should be up to the team who build and maintain it.
  • #74: As a higher-order benefit of decoupling both our codebases and our release cycles, we get a long way towards having fully independent teams, who can own a section of a product from ideation through to production and beyond. Teams can have full ownership of everything they need to deliver value to customers, which enables them to move quickly and effectively. For this to work, our teams need to be formed around vertical slices of business functionality, rather than around technical capabilities. An easy way to do this is to carve up the product based on what end users will see, so each micro frontend encapsulates a single page of the application, and is owned end-to-end by a single team. This brings higher cohesiveness of the teams' work than if teams were formed around technical or “horizontal” concerns like styling, forms, or validation.
  • #78: We should be able to develop a single micro frontend without needing to think about all of the other micro frontends being developed by other teams. We may even be able to run our micro frontend in a “standalone” mode, on a blank page, rather than inside the container application that will house it in production. This can make development a lot simpler, especially when the real container is a complex, legacy codebase, which is often the case when we're using micro frontends to do a gradual migration from old world to new. However, there are risks associated with developing in an environment that is quite different to production. If our development-time container behaves differently than the production one, then we may find that our micro frontend is broken, or behaves differently when we deploy to production. Of particular concern are global styles that may be brought along by the container, or by other micro frontends. The solution here is not that different to any other situation where we have to worry about environmental differences. If we're developing locally in an environment that is not production-like, we need to ensure that we regularly integrate and deploy our micro frontend to environments that are like production, and we should do testing (manual and automated) in these environments to catch integration issues as early as possible. This will not completely solve the problem, but ultimately it's another tradeoff that we have to weigh up: is the productivity boost of a simplified development environment worth the risk of integration issues? The answer will depend on the project!
  • #85: Follow the rules. And there’s also one more win!
  • #86: When following micro frontends approach with Web Components