Lazy Custom Elements: An Undercover Primer

At face value, An Approach to Lazy Loading Custom Elements appears to propose a solution for on-demand loading of web components. It’s actually subtle propaganda for custom elements.

At least that’s how it was conceived: The auto-loader is merely a vehicle to explain, step by step, various stages of implementing a non-trivial custom element (thus the “you won’t actually need all this” note).

This includes the basic setup and vanilla DOM APIs, but also design considerations such as YAGNI as well as configurability and extensibility. A few recurring patterns also make an appearance, such as using getters as a bridge between attributes and properties. Plus we highlight the importance of taking performance into account.

Of course this article merely scratches the surface and there are more elaborate tutorials. It might still be a handy reference, for myself and others – and it’s likely more tangible than earlier attempts.