2

This is not about walking out a particular scenario. It's all about my curiosity. I am just wondering how does rendered/rerender work behind the scene. My first understanding was it stores the related info in view state and read that using javascript to hide/show the related content. But that doesn't seem to be true. When I view the html file in developer tools the rendered hide elements are not there instead of showing something like display: none. So how is that done and how fast is the process?

5

Without getting terribly technical, Visualforce is essentially implemented as JSP; the Visualforce markup is compiled into JSP and run by the Java runtime that renders all of salesforce.

The reason why you don't see hidden elements is because the html is rendered server-side, then delivered to the client JavaScript, which basically drops the compiled code directly into the render targets.

The code runs at about the same speed as native JSP pages, which isn't saying much. You can expect a maximum speed of about 100-200 ms for simple pages. In practice, any page that's worth doing will take close to a second from the initial request to the final rendered state.

I've done benchmarks on this. By using pure client-side rendering and using remote functions can execute the same logic up to 500 percent faster. For example, a Page that takes 100 ms to render using markup can render in 20 ms with a remote action and JavaScript.

The remaining time includes sending the view state, deserializing, serializing, and rendering, plus the additional bandwidth costs, which are most noticeable on slow or laggy connections.

The new, experimental server-side view state feature should bring the entire lifecycle down in response time, but I wouldn't consider that a panacea for all slow Visualforce pages.

  • Thank you for the awesome answer. I am planning to learn some sever side coding to better understand how Salesforce and other website works. Originally I was thinking about PHP. But the fact that Salesforce is using JSP is making me hesitating. Since JSP is pretty much vanishing now, what is your suggestion on this? – Lance Shi Jan 21 '15 at 4:46
  • @LanceShi Don't get me wrong, JSP is still a "valid" approach, just generally considered less responsive than newer technologies. Personally, I'd recommend Ruby on Rails, which is relatively painless and quick to learn, but you'll need to learn a new language (Ruby) to get that far. ASP is also fairly common, but I'm not a fan of the language. PHP is usually what I fall back to when I just need to get things done in a quick prototype, though, so either PHP or RoR would be my top two suggestions. – sfdcfox Jan 21 '15 at 16:27
  • Thank you for that which points me to a broader view. I have read some comparisons now. Do you have any comment for python and Django? – Lance Shi Jan 22 '15 at 1:14
  • I personally like python, although I don't get to use it Murdoch in daily life. Django isn't one I've had the pleasure of learning yet, but now that you've mentioned it, I might have to try it out. – sfdcfox Jan 22 '15 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.