Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web Components ready flag

We are using Web Components and Polymer on our site, and have quite a few bits of Javascript which wait for the "WebComponentsReady" event to be fired before executing. However, we have some asynchronous JS files which occasionally add an event listener for the event after it has been fired, meaning the script we want to run is never run.

Does anyone know if there is a flag for Web Components being ready which can be checked?

Something like this is what we would need:

if(WebComponents.ready) { // Does this flag, or something similar, exist??
    // do stuff
} else {
    document.addEventListener('WebComponentsReady', function() {
        // do stuff
    }
}

Any help appreciated.

like image 634
mjgreen145 Avatar asked Nov 26 '15 11:11

mjgreen145


People also ask

Are web components dead?

We can avoid them using libraries like Lit, Stencil, or Catalyst. The realization that all modern frontend frameworks and many big companies count on Web Components clearly shows that Web Components are not dead.

What's the difference between web components and custom elements?

Web Components consist of three separate technologies that are used together: Custom Elements. Quite simply, these are fully-valid HTML elements with custom templates, behaviors and tag names (e.g. <one-dialog> ) made with a set of JavaScript APIs. Custom Elements are defined in the HTML Living Standard specification.

Will web components replace frameworks?

I think the answer is "yes" - Web Components will replace UI frameworks like React.

What happened Google polymer?

In 2018 Google released Polymer version 3.0, but at the same time they announced that all Polymer elements were put into “maintenance mode” (critical bug fixes only). Instead of working on improvements for Polymer, they created a new library called lit-html.


1 Answers

The following flag is set during bootstrap

window.CustomElements.ready
like image 157
Pascal Gula Avatar answered Oct 05 '22 22:10

Pascal Gula