Inline Scripts

You can listen for livewire:load and place any JavaScript there.
We recommend you use AlpineJS for most of your JavaScript needs, but you can use <script> tags directly inside your Templates.
<!--- Your component's template --->
document.addEventListener('livewire:load', function () {
// Your JS here.
Your scripts will be run only once upon the first render of the component. If you need to run a JavaScript function later, you can emit the Event from the component and listen to it in JavaScript.
Last modified 2mo ago