menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Programming News

>

Web Compon...
source image

Dev

1w

read

275

img
dot

Image Credit: Dev

Web Components: An Introduction

  • Web Components are a way to build components using vanilla JavaScript and widely available browser APIs that can be shared across frameworks.
  • Web Components are divided into two categories, autonomous and custom built-in elements.
  • Autonomous Web Components are more flexible, and Custom Built-In elements are meant to augment the functionality of existing HTML elements.
  • When naming Web Components, the element name must begin with a lowercase letter and include a hyphen.
  • Web Components have specific lifecycle hooks that are used for initialization and cleanup of component instances.
  • Accessibility is an important consideration in Web Components, and ARIA attributes can be used as in regular HTML or a framework.
  • Web Components have a separate scoped piece of the DOM called the Shadow DOM which can be set to open or closed modes.
  • Templates and slots can be used with the Shadow DOM to enhance Web Components by creating reusable snippets within them.
  • Web Components can be used on modern browsers; however, Safari does not support Custom Built-In Elements.
  • Web Components examples were discussed, including Autonomous Custom Element, Custom Built-In Element and Wrapping Up.

Read Full Article

like

16 Likes

For uninterrupted reading, download the app