Re:The broken promise of Web Components
by localvoid on Thursday March 16, 2017 @03:09AM
(#13883130)
I also curious to see how web components will be faster than simple javascript objects :)
React apps are usually built with many layers of components that returns another components. And with standard Web API, there will be significantly more DOM nodes because each component is a DOM node.
Try beating a loop where e.g. every time you get a change you do something like getElementById() + .textContent = newValue. There's no way for React to be faster than that because it has to eventually do the same work but there are many ways for it to be less code, more correct (e.g. by not forgetting to call the update in some cases), or otherwise easier to get to the point where your app can ship.
Someone has tried beating the loop. And more than a loop, but rather a more real-life-like test rendering multiple components and component trees, sets attributes etc. etc. and you can run it on your own computer in the browser
You can check it out yourself: https://localvoid.github.io/uibench/
I highly recommend the author's article about it: https://medium.com/@localvoid/how-to-win-in-web-framework-be...
Re:The broken promise of Web Components
by localvoid on Thursday March 16, 2017 @09:09PM
(#13890536)
Also, it seems that many people are defending WCs with an argument about interoperability. But in reality, if we start adding components that are using different frameworks, there will be problems with layout thrashing, etc, because there is no standard scheduling APIs, and each framework implements its own scheduler to batch reads and writes https://github.com/ampproject/amphtml/blob/8a76ee942f329179d...
Yes. If you're already checking for changes yourself then you've basically rewritten React.
Look at the tests for inferno, it is close to js + dom for some things and inside 2x factor for bascially everything if I remember correctly.
The main thing is development speed anyway, fast enough while still easy to write and maintain code.
I'd be interested in seeing those tests.