Last updated on February 28, 2020
Guys, this time I thought to give you a little idea on Component and Web component. Yes, Why I have given a dedicated post on this topic is in building web application this plays a vital role.
If the application requires the same piece of functionality along with UI then you would need this piece definitely. Ok let’s see what it is really. Do we need to give a thought on component or web component.?
Introduction
Component
is nothing but collection of UI elements to represent certain piece of functionality to achieve re-usability
.
Web-component
is a JavaScript framework agnostic(independent) that helps to achieve re-usability.
Use-case
Let’s say feedback-form
is feature to build it inside our JavaScript application where we plan it to use in different application also but same look and feel we need to apply.
In that situation, we will end up creating feedback-form
component as a feature but then later, as said above we are in need of the same component to be used in different application also. To achieve this, we will prefer to use feedback-form component as a web-component
In modern days, we have a development tool available for building web components such as Polymer (Google project), Stencil.js (TypeScript based) . In my opinion Polymer is already mature enough to make use of it (JavaScript based) whereas Stencil web-component compiler is easy to use and build but TypeScript based.
Even you can use vanilla JavaScript web standards for building web-component but that’s not so hard if you want to try it out. If we build web component we can make use of that in whatever JavaScript based framework the application is built. Web component can be a component but not vice versa.
This post is a knowledge share on component and web-component, I will share code snippet in a different post for the same.