1
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Test Laravel Echo</title>
</head>
<body>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pusher/7.0.3/pusher.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/laravel-echo/1.16.1/echo.min.js"></script>


    <script type="module">
        document.addEventListener('DOMContentLoaded', function () {
            if (window.Echo) {
                console.log('Laravel Echo is loaded');
            } else {
                console.error('Laravel Echo is not loaded');
            }
        });
    </script>
</body>
</html>

Here is my simple example to test the Echo is loaded or not I used the echo.min.js however the pusher is loaded successfully. But Received an error that Echo is not defined. could you please help to resolve this issue?

2
  • 2
    This question is similar to: How to use Laravel Echo in blade files, without Vite/Mix?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Jul 25, 2024 at 11:15
  • I wonder if it has to do with you using type="module" for one of your <script> tags, but not the other two (in one of which is where I assume window.Echo = ... is defined). Commented Jul 25, 2024 at 16:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.