+ Start a Discussion
Benjamin KassBenjamin Kass 

ActionFunction Slowness

I noticed unusual slowness in my ActionFunction calls, so set up the following simple test. It should just call 'actionFunctionTest' 5 times, which itself does not have an action, has immediate=true, and rerender=none. 

As is, it takes 4-10 seconds to complete.
If I remove controller="TestClass", just leaving <apex:page> at the top, it only takes 600ms to complete.  ... though even this is slower than I would hope for.

I have not included TestClass, but was hoping someone could explain at a high level what is happening here. Is this expected behaviour? Why does the TestClass have any impact on the timing of this, given that nothing in the class is being referenced or rerendered (at least not intentionally)? Are there any other flags that I can set to ensure that the actionfunction will be a nearly instantaneous call to the javascript function?

Note - in reality, I am using several actionFunctions to perform simple tasks like rerendering messages, and I would like to be able to do this without the overhead of whatever else is happening.
<apex:page controller="TestClass">
        var startTime;
        var counter;
        javascriptHelper = function(init) {
            if( init ) {
                startTime = new Date().getTime();
                counter = 0;
            } else if( counter < 5 ) {
            } else {
                endTime = new Date().getTime();
                alert( 'Total Time: ' + (endTime-startTime) );
    <apex:form >
        <apex:commandButton value="Test actionFunction Speed" immediate="true" oncomplete="javascriptHelper(true);return false;" rerender="none"/>
        <apex:actionFunction name="actionFunctionTest" immediate="true" oncomplete="javascriptHelper(false);return false;" rerender="none"/>