Because scripts inside
@scriptare handled by Livewire, they are executed at the perfect time after the page has loaded, but before the Livewire component has rendered.
https://livewire.laravel.com/docs/javascript#executing-scripts
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I am implementing an admin panel in the TALL Stack style and I have encountered a problem. I have componentized with Livewire and I'm using @script.
The issue is that if I place the component-related codes inside app.blade.php, it works, but if I place them inside the component itself using @script, it gives an error.
To explain further, if I write a simple console.log inside @script, it shows up, but I feel that the JavaScript code added to the project with @script is executed after the initial page load. I'm not exactly sure what to do, can someone guide me?
My Laravel version is 11.14 and my Livewire version is 3.5.
Please or to participate in this conversation.