真的有必要制作和使用新的自定义元素和 Web 组件(HTML 标签)吗?

I'm currently learning Front-end web development and the difference between Vanilla JavaScript, frameworks and libraries (React for example). Now I'm familiar with web components for making new custom HTML tags. As I know, React is made for the same purpose, but when I visited the Instagram website (the first website that uses React that comes to mind) and looked at the HTML code, I didn't find any custom HTML element, in fact, most of the elements are made of "div"s tags. If a complex social media website like Instagram isn't made of custom elements, then who uses them and why?

解决方案

React is a totally different beast, dating back almost a decade. It was developed by Facebook because TOO many teams were doing TOO many updates in the same DOM. So they came up with a virtual DOM where all required DOM updates are merged before writing to the Browser DOM.

Works great for Facebook. Newer technologies like the Custom Elements API and Svelte (Compile, don't Transpile) have proven it is no longer the best solution.

Reacts outdated technology now scores a meager 71% on https://custom-elements-everywhere.com/

React and W3C Custom Elements are not friends

Because the Green DOM elements are not tracked by React.

And if you want to mix Green and Yellow you have to basically re-write/wrap each and every component into React syntax. Because React not only does DOM Elements different, but also does DOM Events different.

The future

This makes an interesting future: React and the W3C standard are diverging.

And the W3C standard is defacto set by Browser vendors,
not by the W3C, as we learned from the never implemented ECMAScript 4 saga (1999 - 2008)

So its

Apple (Safari) + Mozilla (FireFox) + Google/Microsoft (Chromium/Chredge)
versus
Facebook (No browser!)

'problem' with the W3C is all members have to agree on a standard; that is why it took years for the Custom Elements API to mature... and React got a head start

Facebook does now "own" 60% of the developers market...
but hey,
Microsoft had 90% of the Browser market... once,
and Flash was installed on nearly every device....once

The Custom Elements API will exist for as long as ECMAScript runs in the browser

It is not a framework or library! It is a language construct.
Not learning Custom Elements is like saying:

I am not learning Set or Map, I can do everything with Arrays

Older rant at: Web components - Services / non html components

Or believe the 2020 Front-End Survey:

相关文章