Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Houdinux's avatar

Script Not Executing in Livewire Component View

Hello everyone,

I'm working on a Livewire project and facing an issue where a JavaScript script is not executing in one of my component views. Here's the setup:

I have a main view that dynamically includes different component views based on the value of $activeTab. When $activeTab is set to a specific value, the corresponding view is included.

Example:

<div class="mt-4 ml-4 w-full">
    @if ($activeTab == 'tags')
        @include('livewire.campaign.tags')
    @endif
    <!-- Other tabs-->
</div>

In one of these included views (livewire.campaign.tags), I have a simple script:

<div>
    <!-- Some HTML code -->
    <script>
        console.log('test tags script');
    </script>
</div>

However, this script is not being executed. I'm looking for a way to execute JavaScript within the dynamically included Livewire component views. Any suggestions or solutions would be greatly appreciated!

Thanks in advance!

0 likes
3 replies
Houdinux's avatar

Oh, wow, feeling dumb right now.

Thank you guys, marking the first answer as best answer.

Have a good day.

Please or to participate in this conversation.