Run the script 1 time in the layout

Hello, good morning everyone,

I’m using Livewire + Turbolinks and I want to make a script run only on the first rendering of the Layout, the script is very simple, just start a connection using Websocket and save the state using Spruce

Any idea how I can do this?