with our in-depth screencasts. Watch Now
Livewire offers the ability to "prefetch" the result of an action on mouseover. Toggling display content is a common use case.
prefetch modifier to an action to enable this behavior:
1<button wire:click.prefetch="toggleContent">Show Content</button>23@if ($contentIsVisible)4 <span>Some Content...</span>5@endif
Now, when the mouse enters the "Show Content" button, Livewire will fetch the result of the "toggleContent" action in the background. If the button is actually clicked, it will display the content on the page without sending another network request. If the button is NOT clicked, the prefetched response will be thrown away.