twitter linkedin facebook instagram
  • Home
  • LWC
    • LWC Tutorial
    • LWC Tricks
  • Lightning(Aura)
    • Lightning Tutorial
    • Lightning Tricks
  • Apex
    • Triggers
  • Integration
  • LowCodeLove
  • Interview Q's
  • Misc

Salesforce Socrates


Lightning Web Components are Custom HTML elements built using HTML and modern JavaScript. It is a Programming model based on modern web standards

LWC  Vs  Aura

 

Lightning Components can be built using two programming models: Lightning Web components and Aura Components. Lightning Web Components use core Web Components standards, whereas Aura is a Framework. Although there is a functional difference, LWC can co-exist and interoperate with Aura Programming. To the end-user components built by these two different models appear to be the same.

In the below example we have built two lightning cards, one by LWC and the other by Aura. We notice there is practically no difference between the two.




Why did we need frameworks and what changed now?

 

Until recent year’s web standards were not evolving at a rapid pace, they offered only limited features, which developers needed to build a large scale web application i.e.
rendering engine - It parses HTML, XML, and CSS documents, and the final layout is generated & displayed on the User Interface. In other words, it takes HTML code and interprets it into what you see visually.
standard elements - just as the name implies they are the standard reusable elements,
events -JavaScript's interaction with HTML is handled through events that occur when the user or the browser manipulates a page, and
a core language (ECMAScript 5). An application could not be built on web Components because of the following shortcomings:

  1. Rendering wasn’t optimized for continuous UI transformation.

  2. Standard UI elements were scarce and the standard didn’t support the creation of custom elements.

  3. The core language lacked modern constructs to write large and modular enterprise-class apps at the client-side (modules, classes, promises, decorators, etc).

Multiple Frameworks came up to fill the gap Aura, Angular, and React are to name some. They provided language extensions to support development i.e. modules (AMD and CommonJS), promises, classes, and other general utilities. Different frameworks introduced different component models and HTML templating approaches. Frameworks became different languages; as a result, skills were not transferable. Components written in different Frameworks are not interoperable.

Web Stack of 2019 - more standards, less framework

The need for coexistence, interoperability, and standardization led to the invention of a new set of standards in the community, the idea was to get rid of the layer of abstraction provided by the frameworks and the new task of the framework was to no longer to fill the gap but to provide a thin layer of specialized services for User Experience.

Take a look at the picture below to compare how web standards have changed over the years. All the things that frameworks like Aura had to do are now shifted to Web Standard.

The Lightning Web Components provides a layer of specialized services on top of the core stack, which includes:-
1. The Lightning Base Components
2. Lightning Data Service
3. User Interface API



How can I create a Lightning Web Component?

At the current time, LWC is not supported in the Developer Console. To develop Lightning web Components you will need an IDE tool with sfdx plug-ins - which enables interaction with salesforce org, among many other things. The trailhead module here walks you through the setting up of the Salesforce DX i.e. the tools required for developing and also in the module we will create the "Hello World" Component, which will get us started.




Web components are a set of web platform APIs that allow you to create new custom, reusable, encapsulated HTML tags to use in web pages and web apps.
 
 

Web Components - introduced in 2011, are a set of features which allow creation of resuable components using just HTML, CSS and JavaScript.Features, built on the Web Component standards, can be used with (or without) any JavaScript library or framework (i.e. Aura, Angular, React, and Vue) and will work across all modern browsers.

To understand Web Components, we need to understand how it emerged. The key parameters driving the developments in the realm of technology are - better performance, reusability, standardization, interoperability.

DRY(Don’t Repeat yourself) Principle is one of the guiding principles behind Web components, It’s not a new concept and it has been around for a long time. The idea was to split the components into smaller chunks, which are reusable. However, there are limitations in terms of this implementation. For instance, a react component cannot be dropped as it is into the Angular framework or vice versa.


# How are Web Components filling the gap?


The key difference between web components and proprietary component systems is interoperability. Because they can be expressed as real HTML, they can be rendered by all the popular frameworks. So your components can be consumed more widely, in a more diverse range of applications, without locking users into any one framework.

Web components solve one of the biggest problems that programmers have while building application i.e. reducing repetition. The reason for this principle is that one copy of an element is much easier to maintain than multiple copies if the information needs to be changed, there is only one place to change it. In this way the principle promotes efficiency.

Now consider an application platform, consisting of several applications that are maintained by three different development teams. Each team has its own way of working and uses different tech stacks. Thanks to the reusable and interoperable nature of web components, teams don’t have to build the same components in different frameworks anymore.

# Which brings us to our next question - What are Web Components?


Web Components consist of four pillars that are used together.

  1. Templates
  2. HTML templates allow us to write markup under <template> tag.
    A component that renders UI has an HTML template file and a JavaScript class file.
    Content or markup implemented under <template> tag will not render any content until a script (JavaScript) has consumed the template, instantiated the code, and told the browser what to do with it.

  3. Custom Elements
  4. Custom elements allow for the creation of our own HTML tags or even tweak what is already available and then we can use it in HTML.
    It helps us encapsulate our custom functionality into an element rather than typing long nested HTML elements.

  5. Shadow DOM
  6. Shadow DOM is a web standard that allows you to encapsulate style and markup that can be linked to any HTML element.
    The Shadow DOM is a subtree that branches off the DOM. It hides away the complexity of components from the rest of the page.

  7. Imports
  8. How do we load an image in HTML , using an <img> tag, video had <video>. How do you import a HTML page?
    Just like how we import JavaScript and CSS in HTML using <link> or <script>, we can import another HTML page with the <link> tag.
    Include an import on your page by declaring a <link rel="import" href=” http://example.com/elements.html”>

# In Conclusion - The Future is Bright


Looking to the future, it’s clear that web components are the way forward. For more information on web Components read the official document in which you will find all about web components, custom elements, shadow DOM, and best practices.

Stay tuned.

Trending

Search This Blog

About Me

About Me

LET’S STAY CONNECTED

Total Pageviews

Labels

  • aura
  • Lightning web components
  • LowCodeLove
  • Salesforce Tips
@INSTAGRAM

Twitter

Tweets by sirireddy2212

Pages

  • About Me

Blog Archive

  • ▼  2020 (5)
    • ▼  September (1)
      • "Invoke multiple apex methods" - from single light...
    • ►  July (2)
    • ►  June (2)
Created By SoraTemplates | Distributed by GooyaabiTemplates