MALIKA KAROUM

MALIKA KAROUM

  • Home
  • Inleiding
  • Unite Arab Emirates
  • Blog
  • video’s
  • Promotion
    • Worth for free now
    • Work from Home 2023
    • Gadgets
    • All about Windows
    • about Whatsapp
    • Whats the
    • About websites
    • New Ways
    • New Way of Watching
    • Virtual
    • Website
    • All about Video
    • How to Use
    • YouTube Info
    • All about Twitter
    • The Best of
    • About Apps
    • Google News
    • For Free
    • About This
    • Need More
    • Why should you
    • Iphone news
    • Interesting News
    • About Amazone
    • Some tips
    • About Netflix
    • All about Music
    • About Facebook
  • Marketing
    • Malika Karoum Strategie Modules
    • Malika Karoum Online Marketing
    • Malika Karoum Business Service
    • Malika Karoum Marketing Platform
    • Online business marketing
  • Luxury
    • The Indulgence Business site
    • The Luxury Web site
    • The Ultimate Indulgence
    • The Indulgence Site
    • The Ultimate Luxury Information site
    • Online luxury
  • Malika Karoum
    • Malika Karoum LinkedIn
    • Malika Karoum Facebook
    • Malika Karoum Instagram
    • Malika Karoum Business News
    • Adverteren grote fraude
    • Menu POS
    • Malika Karoum Evenementen
  • Security
  • Malika Karoum link
  • Home
  • Malika Karoum Global News
  • What Is Component-Based Architecture and Why Does It Matter?
March 25, 2023

What Is Component-Based Architecture and Why Does It Matter?

What Is Component-Based Architecture and Why Does It Matter?

by Malika Karoum / Sunday, 04 October 2020 / Published in Malika Karoum Global News

Web components let you create custom HTML elements. You’ll find web components used most frequently in modern front-end JavaScript frameworks. But “Web Components” is actually a W3C web standard and doesn’t need a framework to be useful.

What Are Web Components?

Web components work like Lego for HTML. They are a collection of technologies that help make HTML more useful and reusable. For more background, check out the W3 Web Components specification and the Mozilla Developer Network’s page on Web Components.

These technologies are:

  • Custom elements
  • HTML Templates
  • The Shadow DOM
  • ES Modules

Let’s take a look at these in turn.

Custom Elements

Custom elements are special HTML elements that JavaScript makes more functional. They are best used to display always up-to-date data without callbacks. You can also name them anything you want.

HTML Templates

Templates are reusable chunks of HTML. They’re great for items that go in multiple places or on multiple pages like headers, footers, and menus.

The Shadow DOM

The DOM is the glue that binds what you see in the browser to the HTML code The Shadow DOM is a part of the DOM that lets you keep markup, style, and functionality separated.

By using the shadow DOM, each custom element can get its own DOM. Doing this keeps styling and JavaScript functions from modifying elements that you don’t want to be affected.

ES Modules

These are the special JavaScript libraries that make web components work.

One of the major advantages of web components is that you can reuse your custom HTML anywhere. Because web components are plain HTML and JavaScript, they’re compatible with vanilla JavaScript apps, as well as frameworks. You can learn more at webcomponents.org.

Web Components With a Framework

The easiest way to start using web components is with a framework. Before web components were even around, Angular.js provided a similar functionality called directives. They did a lot of the same work as components, before components became a standard.

Now that components are a standard, there are other frameworks that build on the web component concept. They make using web components easier and more streamlined, as well as abstracting away much of the complexity of using low-level JavaScript.

Vue

Vue.js is a popular component-based front-end framework that is a favorite among developers. Vue is easy to learn and easy to program. The framework also makes it easy to add simple components to basic HTML websites.

Related: What Is Vue.js?

React

React is a front-end framework that has been widely adopted commercially. This framework is also a favorite among developers. React is best known for simplifying web development by putting HTML, CSS, and JavaScript into a single script.

To learn more, have a look at our roundup of tutorials for learning React to make web apps.

Web Components Without a Framework

You can write web components in plain JavaScript. But it’s hard to do so, especially for beginners. There are lightweight libraries that you can add to your existing code, though. They give you the ease of modern JavaScript practices without the high overhead of a full framework.

Polymer

Polymer is Google’s contribution to the web component movement. It’s a collection of lightweight libraries that make creating custom elements easier than with plain JavaScript. It has libraries for creating custom elements as well as templates.

Polymer has a library for polyfills to ensure compatibility with older browsers. There is also an early release of material design components to add material design to plain HTML.

Slim

Another option is Slim.js, an all-in-one library that makes it easy to add to a simple website. It streamlines the custom element creation process and provides direct access to the shadow DOM.

Stencil

Last but not least is the excellent Stencil, which gives you the best of both worlds. It’s similar to React and provides a lot of the same functionality. But it gives you that framework-level functionality without locking you into a heavy-duty framework.

Stencil also pre-compiles your components, which makes them lighter. In contrast, frameworks like React load the whole framework into the browser and compile components on the fly. By the time Stencil components get to the browser, they’re just vanilla JavaScript and HTML with no extra baggage.

Web Components and Web Design

One of the major hurdles of using components is the loss of design frameworks, like Bootstrap. Technically, you can use Bootstrap with a component-based website. And there is a Bootstrap port for React. But if you want to use something like Stencil or Vue, you may be unhappy with the lack of compatibility between your components and the framework.

Traditional Web Design Frameworks

The good news is that there are several design frameworks to choose from. Vaadin provides some beautiful components. For an enterprise flavor, there’s OpenUI5. And as mentioned already, Google’s Polymer offers Material UI components as well.

The bad news is that you won’t find the same experience that you get from Bootstrap in any of those frameworks. And they’re missing many elements you see in most design frameworks, like typography.

What Is the Component-Based Design Framework Approach?

A different technology, like web components, deserves a different approach. Tachyons is the best approach. It’s easier to use for designers, but it can give developers a solid and clean foundation. Tachyons is mobile-first and provides a consistency of design that’s subtle yet generates beautiful results.

Tachyons breaks down CSS classes to the smallest possible use. For example, this is how you create a button using it:

<a class="f6 link dim br3 ph3 pv2 mb2 dib white bg-black" href="#0">Button Text</a>

In most design frameworks, you’d give the link a class of button and another class to round the corners. In Tachyons, you choose your padding, border, color, etc. on the fly. All the abbreviations may seem complicated at first, but they follow a consistent naming pattern that’s easy to learn.

The smallest possible class is an approach that doesn’t work for traditional websites because it clogs your HTML classes. But with component-based architecture, you’re probably going to use that same button over and over throughout your app. That means that you only need to create that button once for your whole website.

Thinking in Components

Another hurdle is getting your brain to change gears from traditional website layouts to component-based structure. There are two techniques to help you learn to think in components.

The Atomic Approach

Think of a web page as an organism. The parts like the hero section, price guide, and user reviews are like the cells of the organism. These are pieces that you can safely move to their own components, whether you reuse them or not.

The buttons, headers, and quotes are like atoms. Atoms are the smallest possible part. When it doesn’t make sense to break a component down further, that’s an atom. These are usually components that you’ll use over and over throughout your project and possibly between projects.

The DRY Approach

Or you can just forget all that organism, cell, and atom nonsense and keep it DRY. DRY stands for Don’t Repeat Yourself.

Anything, big or small, can be a component. So just write your HTML as usual. When you find something you want to reuse, like a gallery or footer, break it out into its own component.

Should You Use Web Components in Your Next Project?

The main points to consider are your team and web standards.

All major browsers have adopted web components. CanIUse rates custom components at a 93 percent adoption rate and templates at 95 percent, so they’re safe to use. And there are polyfills for the few stragglers that don’t support web components. That means that compliance is a non-issue.

If you have a team with no experience in frameworks or JavaScript, they may struggle to adopt this new technology. But they’d likely struggle to adopt any new technology if that was the case. And if you’re alone, go for it! It’s always a good idea to build up your skillset.

The hardest parts of adopting web components are the shortage of design frameworks and learning to think in terms of components. But we’ve covered both of those. Web components have been around since 2014, so they aren’t a new technology. But they are a better technology.

MakeUseOf – Feed

  • Tweet
Tagged under: Architecture, ComponentBased, Matter

About Malika Karoum

What you can read next

Binge-Watching vs. Binge-Racing: What It Is and Why You Should Try It
Twitter Goes Beyond 140 Characters, But It’s Not All Good News
Xiaomi Yeelight Smart Wi-Fi Light Strip Review & Giveaway

Malika Karoum Blog 2023

  • How to Delete the Last 15 Minutes of Your Google Search History

    There’s a quick way for you to clear your...
  • Lenovo Wants You to Know Its Yoga Pad Pro Can Be Used as a Portable Switch Display

    Sometimes, when playing with your Nintendo Swit...
  • The 5 Best Apps for Buying and Selling Pre-Owned Books

    We’ve all been at the point where we have...
  • Humble’s Recent "Heal Covid-19" Bundle Raised 1.2 Million for Charity

    To help raise money for COVID-19 relief in Indi...
  • Nintendo Partners With PlayVS to Make Its Games Recognized High School Varsity Athletics

    It’s odd—Nintendo gets a lot of flak for ...
  • The Pros and Cons of Playing Video Games on an Emulator

    If you’re a fan of playing retro video ga...
  • 5 Curators to Find the Best Articles Worth Reading on the Internet

    When anyone and everyone is a publisher, it isn...
  • Apple Could Unveil iPads With OLED Screens in 2023

    Apple only just switched from LCD to mini-LED d...
  • What Is Signal and How Does It Work?

    The chances are that you use at least one of th...
  • Samsung’s Upcoming Flagship Exynos Chipset Will Feature AMD’s RDNA2 GPU

    AMD confirmed its partnership with Samsung at C...
  • Atari Finally Reveals the Launch Date for the New Atari VCS Console

    At last, after what seems like an age (it pract...
  • Twitter Starts Testing Full-Screen Ads in Fleets

    Twitter has announced that it will be adding fu...
  • When Is Facebook Messenger Going to Offer End-to-End Encryption?

    Facebook Messenger is easy to use and has great...
  • Get Paid to Play Apps: How They Work and What You Risk

    You’ve probably seen advertisements for a...
  • When Will PS5 Production Ensure Supply Meets Demand?

    Despite the PS5’s launch taking place in ...
  • How to Manage Processes on Ubuntu Using System Monitor

    Linux, like most modern operating systems, is v...
  • How to Get Verified on Twitter and Finally Get That Blue Check Mark

    Twitter, like most social media platforms, offe...
  • 10 Street Photography Tips That Will Make You a Better Photographer

    Street photography is enjoyed by many enthusias...
  • Huawei Freebuds 4i Review: Quality ANC Earbuds for $100

    Huawei Freebuds 4i 8.00 / 10 Read Reviews Read ...
  • What Is Extended Reality (XR) and How Does It Work?

    We’re living in a digital age where the virtual...

MALIKA KAROUM ONLINE MARKETING PLATFORM

Office:
RME HOLDINGS SARL – DUBAI BRANCH

BUSINESS CENTER

Parcel ID: 345-835

Area: Bur Dubai

Sub Area: Burj Khalifa

UNITED ARAB EMIRATES

 

 

 

Malika Karoum Concept

Malika Karoum Projects

  • GET SOCIAL

© 2014 Malika Karoum -United Arab Emirate Dubai- All Rights Reserved

TOP