Home › Forums › Backend Issues (wp-admin) › JS performance issues › Reply To: JS performance issues
Hi,
Me again. I’ve been digging into the actions called after clicking Add new repeater field. It calls acf.fields.repeater.add which at the end triggers setup_fields event:
$(document).trigger('acf/setup_fields', new_field);
The event itself runs fast but then it gets propagated into gazillion of other elements. Not sure why. Maybe because you use $(document)?
Regardless of the above I’ve changed the event handler to stop the propagation:
$(document).on('acf/setup_fields', function(e, el){
e.stopImmediatePropagation();
$(el).find('.repeater').each(function(){
acf.fields.repeater.set({ $el : $(this) }).init();
});
});
And now adding new repeater fields happens in an almost instant, regardless of how many are already there. Not sure if this will affect other functionality but I didn’t notice anything unusual so far. Please consider whether this can be a permanent fix.
Possibly the same is happening in Flexible Content field. Sorry folks I don’t have this plugin so I can’t test it.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.