function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Chinmay BhusariChinmay Bhusari 

How much importance should be given to javascript to develop efficient visualforce pages?

I am confused on how much knowledge of javascript is required to develop efficient visual force pages and while doing visualforce coding how much percentage of the code should be controlled by javascript (according to the requirement)?
Best Answer chosen by Chinmay Bhusari
bob_buzzardbob_buzzard
This really depends on a number of factors.  If users have a slow network connection or you are developing a mobile application, then JavaScript may be the way to go.  You can use a blend of JavaScript and VF, by generating the initial page using VF and then use JavaScript to make updates, remoting to retrieve additional information etc, and that will give a decent speed increase without having to move all of your business logic to the front end.

If you are writing a mobile application, then my advice would be to write all of your business logic in JavaScript and reduce the number of requests to the server to an absolute minimum, as requests from a mobile device are always quite expensive and involve latency, especially if the user is changing cells frequently.

One of the problems with JavaScript served from Visualforce is that its difficult to automate the testing - you can't use the Salesforce testing framework as this is built for Apex, so you'll need to look at a third party solution.

My advice to customers is usually to avoid JavaScript, as its more difficult to write, maintain and test, unless there is a good reason to use it, in which case use it and don't feel bad about it.  In short, no JavaScript until its time to use JavaScript :)

All Answers

bob_buzzardbob_buzzard
This really depends on a number of factors.  If users have a slow network connection or you are developing a mobile application, then JavaScript may be the way to go.  You can use a blend of JavaScript and VF, by generating the initial page using VF and then use JavaScript to make updates, remoting to retrieve additional information etc, and that will give a decent speed increase without having to move all of your business logic to the front end.

If you are writing a mobile application, then my advice would be to write all of your business logic in JavaScript and reduce the number of requests to the server to an absolute minimum, as requests from a mobile device are always quite expensive and involve latency, especially if the user is changing cells frequently.

One of the problems with JavaScript served from Visualforce is that its difficult to automate the testing - you can't use the Salesforce testing framework as this is built for Apex, so you'll need to look at a third party solution.

My advice to customers is usually to avoid JavaScript, as its more difficult to write, maintain and test, unless there is a good reason to use it, in which case use it and don't feel bad about it.  In short, no JavaScript until its time to use JavaScript :)
This was selected as the best answer
Chinmay BhusariChinmay Bhusari
Hi bob_buzzard,

Thanks a lot. Very informative answer.