How to Speed Up a Laggy Form

My form is very laggy and it seems to be due to “GFCalc.runCals”. Is there a way to limit calculations & conditional logic to the fields on the current page (ie. only the calculations and conditional logic for fields on the current page are evaluated?)

A less ideal approach would be to initially replace the “Next” button on each page with a “Calculate” button that needs to be clicked before the “Next” option appears.

I’m sitting with this now - our form basically didn’t work on an ipad due to too many loops. The problem is the design of GF where it runs the calculations multiple times per page. There doesn’t seem to be any “smart” functionality built into it. It slows down a LOT once it gets complicated.

What I’ve done is: Put our calculations into an external javascript instead - then hook it into jQuery(document).on(‘gform_post_render’, function() { … } )
This will only run once per page - when the next one renders - i.e. do calculations for page 1 on page 2. Our last page in the form is only a “show results” page before you click Submit. But this may not be useful if you need to see the results as the numbers change.

I don’t know for sure, but I think the only way to limit calculations to only the current page would be to daisy-chain forms. I.e. do one page as a form - send the results to the next form and so forth.

1 Like

@Joker How complicated is your solution’s code? That sounds like what I need (ie. very similar to the second solution I outlined), but I’m not a developer.

I have run into this issue on various forms and it’s weird that GravityForms doesn’t have more “smart” functionality built into it’s calculation & conditional logic evaluation…Or that a plugin doesn’t exist to optimize/speed things up.

Define complicated? :smile:

My solution is creating a separate custom.js file to the theme - load it in functions.php - and then create the calculations on both javascript and php. Each field you’re doing this for needs its own calculation on both the front- and backend.

I suspect it may be too complicated as a non-developer. I’m a developer, so not complicated in itself - just takes some time to get right (and if you’re using the partial-entries addon it gets downright annoying).

For a non-developer I think the best solution is the second one I outlined - chaining forms together.

I’m still working seeing if there is a simpler method - I have a few idea, but haven’t tested them yet. :slight_smile:

@Joker, I found this older post which seems to outline a very short solution, but I’m not sure how to tweak it as per the author’s “If breaking into multiple pages is not viable…” paragraph. I’m fine with multiple pages, but can’t wait to calculate until the last page…I’m also not sure whether this would work with the current version of GravityForms.

He’s basically delaying calculations until last page. Perfectly viable if you don’t need them before, and a pretty simple solution to it.

How would I modify this snippet to delay the calculations until going to the next page/submitting the form (ie. to run at the end of each page rather than only on the last page)?

If breaking into multiple pages is not viable for one reason or another, the solution would be to proxy it ( _proxy_gformCalculateProductPrice = gformCalculateProductPrice; ), override the [Next/]Submit button behavior to show “Calculate” first, which calls _proxy_gformCalculateProductPrice(); , renames the button to [“Next”]/“Submit” and allows the form to [go to the next page] / be submitted thereafter.

@Joker or anyone else know how to modify this code as outlined?

I would really appreciate help modifying the code as indicated above.

© 2008 - 2019. Gravity Forms is a project by Rocketgenius Inc.