You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I took over a laravel project which uses livewire and jetstream for their team management. The management page in particular, but also other places in this application, have extremely slow loading times. What struck me most is that the view file in use for the team management is a nearly 1:1 copy of stubs/livewire/resources/views/teams/team-member-manager.blade.php. With about ~300 users, this site takes over five seconds to render and the main problem seems to be the repeated check in line 142 (Gate::check('updateTeamMember', $team)) and 159 (Gate::check('removeTeamMember', $team)). Putting these checks at the top and caching the answer for use in the loop later, drastically reduces and fixes this performance issue.
Now, I am fairly new to laravel/livewire. Is there any reason not to do that check outside the loop? The variable $team does not change and there seem to be no other side-effects.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I took over a laravel project which uses livewire and jetstream for their team management. The management page in particular, but also other places in this application, have extremely slow loading times. What struck me most is that the view file in use for the team management is a nearly 1:1 copy of stubs/livewire/resources/views/teams/team-member-manager.blade.php. With about ~300 users, this site takes over five seconds to render and the main problem seems to be the repeated check in line 142 (
Gate::check('updateTeamMember', $team)
) and 159 (Gate::check('removeTeamMember', $team)
). Putting these checks at the top and caching the answer for use in the loop later, drastically reduces and fixes this performance issue.Now, I am fairly new to laravel/livewire. Is there any reason not to do that check outside the loop? The variable
$team
does not change and there seem to be no other side-effects.Beta Was this translation helpful? Give feedback.
All reactions