[SalesForce] Lightning Web component and Aura component performance difference due to the change in architecture

I am new to salesforce lightning web component.I did some of the example and found that lightning web component is way more faster than Aura component. This is due to the web stack architecture of aura component and lightning web component.

Aura component follows traditional web application architecture:
enter image description here

Lightning web component follows web application with web component:
enter image description here

can anyone please explain me with example, how lightning web component manages most of the processing at web standard level whereas aura component is handling those at Framework level when both have same javascript and apex controller at the backend?

Best Answer

Aura was originally developed before the finalization of the web standard Web Components. Before this specification came out, each framework (ReactJS, Aura/Lightning, etc) had to fully take over the DOM that JavaScript provides, providing custom filter functions to enforce security, transpile CSS rules to prevent components leaking CSS to other components, and so on. In other words, the framework was only as fast as the JavaScript engine it ran on.

After this standard was released, and browser vendors implemented it, many tasks that were previously performed in JavaScript could now be enforced by the browser. This is a much faster solution, because it can be optimized in a way that JavaScript cannot; the browser is much faster at rendering the DOM than it is executing JavaScript.

If you read the linked page (Web Components), you'll notice many similarities to LWC. This is because LWC is based on the standards. Salesforce and other vendors originally helped create the standard to begin with.

To give a different comparison, Aura is like software 3D graphics rendering, while Web Components is like hardware 3D graphics rendering. Hardware always performs better than software for the same algorithm. As stated before, this is the main difference between Aura and LWC; the former must be rendered entirely in software, while the latter is rendered mostly by the browser.

Note, however, that for supported platforms that do not implement Web Components (e.g. IE 11), performance for both Aura and LWC are about the same, since LWC has to be "emulated" by JavaScript software instead of browser functionality.

Finally, as an aside, newer frameworks are also using Web Components. It's not specific to just Salesforce. They implement them using different syntax structures, but the main benefits of moving to Web Components are improved encapsulation (and thus, security), as well as improved performance. The "traditional web application" model is slowly falling out of favor in exchange for a faster, more secure World Wide Web.