Can you recreate it here? https://jsfiddle.net/dy2ork0f/
My example does not show it twice for me.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
app.blade.php
<head>
<script defer src="https://unpkg.com/[email protected]/dist/cdn.min.js"></script>
</head>
<body>
post.blade.php
<div x-data="{ }">
<button @click="console.log('Click!')">Click it!</button>
</div>
Why is this code running twice when I click ONCE ?
Ah I was able to recreate it. Just load alpine twice. So it seems you are loading it twice somehow. Either via 2 scripts (in different places) or perhaps also in your compiled app.js ?
Loaded once by jsfiddle, and I also load it on the page: https://jsfiddle.net/vj1rfugs/
Please or to participate in this conversation.