Visualforce, an essential component-based user interface which is in the hot talks these days. It is very popular and frequently used for developing the custom pages in salesforce.com. In this blog, I will let you go through the concept of Visualforce and will make you understand its essential advance level features. Let’s just quickly know why Visualforce is important.
Importance of Visualforce
There is a much buzz about Visualforce for its implementation paradigms in the applications. But the real importance of the Visualforce stands in the following points:
- It provides the user-friendly development features.
- Healthy integration with other web-based user interfaces.
- Model-view-controller(MVC) style development support.
- Visualforce has data-driven
- It is automatically upgradable.
- Visualforce has a concise syntax.
These important points help in creating the awesome web and mobile applications. Now, let me brief you about what actually you will get to know in this blog:
- What is Visualforce?
- How can you improve the performance of existing Visualforce pages?
So, let’s just first eye upon what actually is Visualforce.
What is Visualforce?
If you are from the salesforce background then you must be in a habit of listening to this term very frequently. Isn’t it? If not, then no issues, here in this section I am going to let you know about it. Just stay there and read further.
As described in the starting Visualforce is nothing but a web development framework that provides features to build the custom and sophisticated user interfaces. These interfaces are most frequently used for mobile and desktop applications that can be hosted on the lighter platforms.
Now, that you have enough overview of what Visualforce is and what is its importance, So, let’s just proceed further to know the extremely productive habits that can result in the highly optimized Visualforce page.
You should also check: 10 Reasons to Use Angular in Salesforce Visualforce Pages
Top 5 most productive habits for optimizing the Visualforce pages
There are always some methods in every programming language, frameworks, and tools to optimize the tasks and build the feature-rich application. So, same is the case with the Visualforce. You must adopt these 4 habits to make your application a feature-rich application.
Following is the list of these habits.
Review the HTML that is generated by Visualforce components. Visualforce pages require valid HTML during compilation.
For example, if you have a <head> or <body> tag inside of your <apex: page> tag, the Visualforce page removes it at runtime.
Unnecessary HTML also increases the size of the component tree and the processing time for Ajax requests in Visualforce.
- Combine all the CSS files into a single file to reduce the number of HTTP requests.
- Remove comments and whitespace (spaces, newlines, and tabs), and compress the resulting file for faster downloads.
- For pages that don’t use Salesforce CSS files, set the <apex: page> tag’s show Headers and standardStylesheets attributes to false.
NOTE: This practice excludes the standard Salesforce CSS files from the generated page header.
2. Improve the View State Size of Visualforce page
View State is the amazing feature that is provided by Salesforce for identifying and controlling the tree component of the Visualforce page.
Salesforce provides the 135 KB maximum size as per the governance limit. For Reducing the size of view state, your page should be quicker and stall less often. Following are the points that must be kept in mind:
- Try to use the transient keyword in your apex controller class for variables. This would help in maintaining the state and it wouldn’t store in view state during page refreshes.
- If your view state is affected to a large component tree, then at that time you can reduce the number of components that depend on your Visualforce
3. Focus on improving the Visualforce page Loading Time
The large size of the Visualforce page directly affects the page load time. So, to reduce the load time you can follow below best practices which are introduced by salesforce lazy load.
- You can store cache data that are used frequently. Like icons, read-only messages etc.
- Avoid SOQL Query in your apex controller for getter functions.
- Try to display minimum numbers of records as per requirements.
4. Avoid Multiple Concurrent Requests
Concurrent requests are long running tasks that tend to block the other pending tasks. So, to avoid this thing you may opt to do the following things:
- Try to use action methods used by <apex:actionPoller> which are lightweight. It’s a best practice to avoid performing DML and external service calls.
- Tasks are likely to be blocked when the method is used on a widely distributed, or continuously active page. So, try to avoid it.
- Increase the time interval for calling apex from your Visualforce page. For example, when using the <apex:actionPoller> component, you can adjust the interval attribute to 30 seconds instead of 15.
- You can use non-essential logic for an asynchronous code block using Ajax.
5. Prevent Field Values from Dropping Off the Visualforce page
Pages with many fields, including large text area fields, and with master-detail relationships to other entities, can sometimes fail to display all data. To improve on that, the following points can be considered:
- Data can be dropped due to limits on the size of data returned to Visualforce pages and batch At that time, you may get a warning: “requested too many fields to display. Consider removing some to prevent field values from being dropped from the display.”
- To prevent field values from being dropped from the page, remove some fields to reduce the amount of data returned. Alternatively, you can write your own controller extensions to query child records to be displayed in the related lists.
These were the top 5 habits that can really improve the Visualforce pages in terms of page loading and various other performance aspects.
It’s the best practice which is recommended by the Salesforce to develop and customize the Visualforce pages.
Habilelabs is a premier software development company that provides professional services for the development of the Visualforce pages and their customization as per the standards of Salesforce development. It is rich with the resources to develop the feature-rich applications using Visualforce pages. Give us a call to find out more about our awesome services!
I hope this blog must have attracted you towards the Visualforce and its features. For any queries, you may feel free to comment in the comment section. You can also share views for the blog in the comments section below.