Web Components !== silver bullet

During and after the Web Components panel in Edge Conf 3 I witnessed something that left me super puzzled: it seems that people expect Web Components to be the solution to all the problems.

It might be due to the fact that WC are a confusing matter, that there are several ways to define and use them, that the spec is in constant change and there are also many dissenting voices about the whole business. Despite all this, Web Components are still HTML + JS + CSS. They are still subject to the same rules, principles and professional standards that all your code is/should be subject to already.

Yet I keep seeing people extremely concerned that “there will be crappy components” and “the need for performance” and “accessibility” and etc–Addy Osmani summarised it in a tweet:

When creating Web Components, keep in mind:

☑ Accessibility
☑ Performance
☑ Re-usability
☑ Responsiveness
☑ Namespacing
☑ Docs & Testing

and Paul Lewis expects/hopes all Web Components will be built upon three dead boring but essential pillars: accessibility, security and performance.

But this is how you should be developing anyway.

If you expect someone else to build components for you that will solve all your current and future issues: tough.

If you expect someone else to be responsible for you: tough.

Web components are just a tool that will enable you to write better and encapsulated front end code.

They are not a silver bullet that automagically makes everything work.

Just as we can have closures and functions and the code inside those doesn’t necessarily have to be seen from the outside, so you can do with web components, and write reusable pieces of code instead of dropping bunches of nested divs with lines-long class attributes into your DOM tree. But just as with closures or functions or any other technique or tool, using them doesn’t guarantee your success. Thinking otherwise is delusional.