Lightning vs Visualforce
There are lots of questions in the mind of Salesforce developers regarding Lightning but the question which comes in every Salesforce developer’s mind is, will Lightning replace Visualforce?
You will be able to answer this question after exploring the Lightning Experience and VisualForce.
Lightning Experience is not finished yet. There is plenty of work for developers to do just building out the basic Salesforce application. Many things are working great, some things are working well in “Beta”. As it is in “beta” version there are a number of things we just haven’t gotten to yet.
We are living in a multi device world where users are expecting highly interactive and immersive experiences literally at their fingertips. Companies like Google, Facebook are making user experience highly interactive using isolated components. Online forms now come with immediate error feedback when users enter invalid data. This interactivity is no longer a novelty, it’s the norm.
So what does this mean for us?
The Visualforce framework provides a robust set of tags that are resolved at the server-side and that work alongside standard or custom controllers to make database and other operations simple to implement. This is a page-centric web application model. It’s great for basic functionality, but it’s challenging to deliver the new, more dynamic experience that users expect. Fundamentally, this is because it relies on the server to generate a new page every time you interact with the application.
Both the page-centric and app-centric models have their own advantages and both are here to stay. Combining the models lets applications deliver the right type of experience for the right use case.
Let’s explore the differences between Lightning and Visualforce.
- User requests a page
- The server executes the page’s underlying code and sends the resulting HTML to the browser
- The browser displays the HTML
- When the user interacts with the page, return to step one.
- Tried and true model
- Easy to implement for greater productivity
- Naturally splits large applications into small, manageable pages
- Has built-in metadata integration
- Higher latency
- The user requests an application or a component
- The application or component bundle is returned to the client
- The browser loads the bundle
- Enables highly interactive and immersive user experiences
- Aligns with Salesforce user interface strategy
- Built on metadata from the foundation, providing an integrated developer experience
- The Developer Console supports Lightning components, so there’s an integrated developer experience
- Higher learning curve compared to Visualforce
- Higher complexity than Visualforce—you’re building an application, not a page
- Since Lightning components are new, there are still some features that aren’t supported
- There are a limited number of out-of-the-box components
You have gone through pros and cons of Lightning and Visualforce now you have to decide which tool you should use.
Here are some guidelines to help you decide-which tool you should use and when.
When you should use Lightning
- If you are developing for Salesforce1 Mobile Application you should use Lightning as visualforce characteristics, especially the page-centric orientation, can be a poor match for mobile apps with limited, high-latency network connections and limited compute resources. Lightning components, by contrast, was designed specifically to handle this context.
- If you are enabling non-developers to build apps by assembling standard or custom components you should use Lightning App Builder and Lightning components for custom components. Use Visualforce if the required components aren’t yet available.
- If you are adding user interface element for example, say you want to add a tab to a record home. This task is a simple drag-and-drop in Lightning App Builder.
- If you are building a Community for Customers you should use Community Builder to create a Lightning-based community site leveraging Lightning components.
- If you are committed to invest in latest technology you should start using Lightning Components.
- If you are starting a brand new project you should use Lightning Components. If you’re not familiar with them, there’s no better time than now to learn!
Continue using Visualforce
- If you are building a page-centric experience with limited Client-Side logic use Visualforce.
- If you are building a community for partners continue using Visualforce in Salesforce Classic. Explore using Lightning components with Lightning components for Visualforce.
- If you are exposing a Public-Facing Unauthenticated Website continue using Visualforce. Lightning components don’t support an anonymous (unauthenticated) user context yet.
- If you are rendering pages as PDF in your application use Visualforce. Lightning components don’t support rendering as PDF output yet.
- If you are adding to an existing project with lots of Visualforce Pages continue to use Visualforce. Consider moving to Lightning components using Lightning components for Visualforce.
Now you are able to decide which tool to use. But, because web applications are taking more advantage of the app-centric model, I will encourage all Salesforce developers to learn at least the basics of Lightning components. You’ll want to use these components in your future development work.