phplaravellaravel-livewire

Laravel livewire repeater loading time


ISSUE

can someone tell me how can I improve the livewire repeater load time? For example when I click on the button to add new input I have to wait about 3s until it appears. Also, sometimes it happens not to be 3s, instead, it is 10-12s.

IMAGE

Network loading screen

CODE

public $reviews = [];
 public function newReviewInput()
{
    $addreview = [
        'reviews' => '',
        'score' => '',
        'source' => '',
    ];

    array_push($this->reviews, $addreview);
}

When the button is clicked, I call this function which adds a new value to the array, which is looped over to display new inputs.

Is this the optimal way or there is a better one?

Could it be maybe because there are a lot of methods in one component (full-page component)?

Would it help if I separate all of them into smaller ones?

Thanks


Solution

  • The solution that helped me, in the end, is to take all of the components and make them separate instead of one big one. Later on, I have just made a feature to save all changes in all forms at once and to have separate buttons if there is some change :)