Lazy load on custom page
I have created a custom page and copied in my old livewire component. As involves an API call which is a tad slow. Is there a way to lazy load the page? Show some sort of loading width on the page whilst its grabbing the data. At the moment it takes 3-5 seconds to load the page.
12 Replies
custom page is a livewire component. check the livewire docs for lazy loading
I have and I have this working just fine on standard livewire/laravel. But to call a livewire component as lazy you do so when calling the livewire compoenent itself or on the route. Neither which I have access to within the Custom Page file itself. Unless I am missing something silly
maybe you can do it with an attribute. https://livewire.laravel.com/docs/lazy#lazy-load-by-default
Laravel
Lazy Loading | Laravel
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
I did try this actaully. It has a weird behavior whereby it will show me the page I want BUT it takes it out of the panels wrapper and its onto my non filament part of the site. I.e I see my non filament nav bar etc and no filament sidebar/nav at all
first screenshot being the navbar from my NON filament part of the site. and the second image being where I click on to view the custom page. If I take off the #[Lazy] it will laod within the panel wrapper no problem
but not with lazy benefits
so it takes 5 or so seconds to load
only thing i can think to do then is too make an 'internal' livewire component for the page to use, then you can do lazy in the view like you are used to.
and just pass the record to the internal LW component
if there is a record
okay okay, I think I follow you. I'll give that a whirl an report back
thank you
that worked a treat. Page loads fast and the data come a few seconds later. Only thing I need to figure out is all the tailwind styles have not been applied
you'll need a custom theme so it can scan your views directory for classes
I do have a custom theme already ( albeit only freshtly created it last night ) so I may not have configured that correctly yet
or you need to run a build
at least it's working. π
and fixed
thank you so much