A minimalistic, framework agnostic, lazy Custom Elements loader
npm install uce-loaderSocial Media Photo by Guillaume Bolduc on Unsplash
A minimalistic, framework agnostic, lazy Custom Elements loader.
``html`
If loader({container: document, on(tagName){}}) API is too simplified, feel free to check lazytag out.
If your components use attachShadow and internally use custom elements that should be lazy loaded, be sure the shadowRoot is observed.
`js`
const shadowRoot = this.attachShadow({mode: any});
loader({
container: shadowRoot,
on(newTag) {
// ... load components
}
});
Current version of this module does not invoke the .on(...)` method if the element is already registered as Custom Element.
In V1 any tag name would've passed through the loader instead.