Essentially WebComponent is the way of associating some JS class with custom DOM elements.
At the nutshell, WebComponents is just this one JS function:
customElements.define('hello-world', HelloWorld);
That element->JS code binding could be done by CSS with much greater flexibility:
/* custom element */ hello-world { aspect: HelloWorld url(hello-world.js); } /* existing element */ span.hello-world { aspect: HelloWorld url(hello-world.js); } /* existing element, conditionally */ a[href^="http"] { aspect: HelloWorld url(hello-world.js); }
Essentially WebComponent is the way of associating some JS class with custom DOM elements.
At the nutshell, WebComponents is just this one JS function:
But it is quite limited as you see - a) only custom elements and b) you need to load some JS file in order to initialize bindings.That element->JS code binding could be done by CSS with much greater flexibility:
Yet note that, in case of CSS bindings, hello-world.js will be loaded only if your document will have matching elements - better componentization I would say.