Support

Account

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.