You must read this official Salesforce blog post to get more background details on why and what of lightning web components.
Web Components"Web Components is a suite of different technologies allowing you to create reusable custom elements — with their functionality encapsulated away from the rest of your code — and utilize them in your web apps." - Mozilla
In short, prior to web components, one had to utilize an external library/ framework (like Angular, React etc.) and build your application on top of it. So essentially, your application runs on top of the external library/ framework and which in turn runs on the browser.
With latest innovations within web development world and addition of custom elements, shadow DOM (don't confuse with virtual DOM), and content template element, browsers are now equipped to execute custom web components themselves, without needing any external library.
It can be related to running a video using HTML video component vs using Adobe Flash for running videos (not quite literally).
Lightning Web Components
Lightning web components, leverages these new web standards (or browser improvements) and allows developers to create web components which can work within Salesforce Lightning platform.
Remember, web components allow you to combine UI and processing. To create a web application, you still need security, access to server services/ data. This is where Lightning web components come into place. Salesforce Lightning web components provides these additional capabilities (security, lightning data service). With these, we can create standard web components which can interact and work with Salesforce Lightning platform.
Additionally, lightning web components can leverage lightning base components (already built on web components), enhancing overall application performance.
Lightning components vs Lightning web components
UsageSimilar to custom lightning components, lightning web components can be utilized to create standalone components which can be embedded within
- Lightning Applications
- Custom lightning components
- Visualforce page (using lightning out)
- Lightning components *
Custom Lightning Components vs Lightning Web ComponentsSo, what is the difference between Custom Lightning components (something that has taken a significant portion of everyone's time in past 3-4 years) and Lightning Web Components. One word answer is Framework.
Lightning components utilize Aura framework for development and execution of Lightning components. Aura framework can be placed in same stack as Angular, React, as it provides the nuts and bolts to run your lightning components.
Lightning web components, on other hand utilize browser provided features for general component scaffolding along with Salesforce Lightning web components framework (which provides features related to security, service integration and base lightning components). As a large portion of this is now native within browser, there is an obvious cost saving in terms of processing overhead.
As lightning web components utilize more of native browser features and capabilities they are:
- Compliant to web standards
- Memory efficient
- Easier to learn and Transferable knowledge
ConsiderationsFor most part, all mainstream browsers support these web standards. However, there is still come catching up to do. For e.g. Edge still do not fully support all these web standards (totally clueless about IE's support for these standards). So, if your organization still uses one of the older browsers or older versions, Lightning web components may not be useful right away.
(Update Dec 15): As pointed out by Diego Ferreiro Val, Lightning web components works on all mainstream browsers, down to IE11.
For more details on browser support of web components, refer https://developer.mozilla.org/en-US/docs/Web/Web_Components#Browser_compatibility
Open questionsThere are still some unanswered questions here:
- As we know Lightning Experience itself is built on top of Aura framework. Is Salesforce planning to re-write entire Lightning experience with newer Lightning web components? I'm sure the additional performance and memory efficiency will be more than welcome
- Would lightning web components become latest de-facto of publishing packages on AppExchange?
- More importantly, with server side rendering of visualforce pages and client side handling of lightning web components, can there is a mixed model to utilize best of both the worlds?
- Most important, would it help load lightning experience home page faster? (pun intended)
Further LearningFor most part, as Lightning web components utilize HTML web components, documentation for that can be found fairly easily.
Following are few learning resources: