Most of the pages in our application have been built using HTML5/CSS/Bootstrap/Javascript Remoting/JQuery/AngularJS. Their controllers have most of the methods with @RemoteAction and other static methods called from remote methods. What are some good practices for such controllers.

1 Answer 1


Few Best Practices I can remember:

  1. Avoid calling remote function in for loop.
  2. Keep payload size minimum in controller
  3. Don't use global/public variables in static method or any approach like this. Keep everything in method.
  4. Sometimes same thing needs to be done again and again for each remoting method in controller. Create a common utility for it.
  5. Remoting count agains API calls, so this limit should be considered.
  6. Users can lose their network connection in mid-transaction, or alter the way that your page’s JavaScript executes with Firebug and other tools. Always do server/controller side checks before returning results or perform action.
  7. Remoting can upsert/insert/update in parallel on same object. Design your method to avoid Record Lock situation.
  8. Use wrapper classes instead of List/Map to return result. This makes the code readable and manageable to your next dev and yourself.
  • I'm fairly certain that remoting calls do not count against the API limit anymore.
    – JCD
    Commented Aug 24, 2015 at 13:33
  • @JCD you may be correct but practically I have seen these calls increasing API count. Lets wait to confirm by other.
    – Ashwani
    Commented Aug 24, 2015 at 13:43
  • I have been running some javascript remoting in my sandbox and it does seem to be increasing the api usage count? Do you know if it actually does count or not
    – Dieskim
    Commented Jan 5, 2021 at 11:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .