All posts

Visualforce Page v/s Lightning Aura Component


To understand the above picture, you should understand few things in the Salesforce ecosystem:

1. Server Side - It refers to the backend where APEX is everything like Apex Trigger, Apex Class, Batch Apex, Asynchronous Apex, Scheduler Apex. All the database manipulations happening in the background of the application are termed as server side.

2. Client Side - It refers to the frontend part where HTML, CSS, JavaScript come into play. Everything happening on a web page like taking an input from user, validations, styling etc. are collectively called as client side.

3. Synchronous Calls are those calls/transactions which can only take place if the previous call is completed. It is a sequential kind of call and hence it is slow because it will have to wait till the last call is finished.

4. Asynchronous Calls are those calls/transactions which are independent of any other call. There is callback function associated with these calls which executes when an asynchronous call's response comes back. Every async call starts a new thread of execution or in terms of Salesforce, a new debug log will be generated for every async call.

By now, everyone knows that Lightning components are better than Visualforce pages. Let's see how it is better and why:

  • Visualforce Page makes synchronous call to Apex class(Server side) which are slow. The page kind of hangs if the request is time taking. The user won't be able to do anything on the page meanwhile.
  • On the other hand, Lightning Components make async call to Apex class(Server side) from the JavaScript controller or Helper(Client Side). The component is alive even if the request is time taking.
Can we replicate Lightning Component's behavior of async calls in Visualforce Page?
The answer is YES, using JavaScript Remoting in VF page we can replicate the exact behavior of Lightning component into a Visualforce Page. To read more about JS remoting, check out this post.

First published on Blogger in 2020. Some screenshots and APIs have changed since; the code is kept as written.