tapio / live-server

A simple development http server with live reload capability.
http://tapiov.net/live-server/
4.4k stars 484 forks source link

Browser doesn't refresh if script tag is added #421

Open thatanjan opened 11 months ago

thatanjan commented 11 months ago
Before submitting an issue, please, see https://github.com/tapio/live-server#troubleshooting

Issue description

I have this HTML

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="styles.css" />
</head>

<body>
    <h1>
        Elit tempore autem natus nobiso
    </h1>
    <h3>
        Sit sapiente ad aliquid similique suscipit veritatis architecto, voluptatum Sunt.
    </h3>

    <button id="open-modal-button">Open My Modal</button>
    <dialog id="customModal">
        <form method="dialog">
            <input type="text" name="" value="" />
            <button>OK</button>
        </form>
    </dialog>
    <script>
        const modal = document.getElementById('customModal')
        const openButton = document.getElementById('open-modal-button')
        const closeButton = document.getElementById('close-modal-button')

        openButton.addEventListener('click', () => {
            modal.showModal()
        })

        closeButton.addEventListener('click', () => {
            modal.close()
        })

        const modal2 = document.getElementById('customModal')
    </script>

    <script src='./index.js' type='text/javascript' />
</body>
</html>

If I keep the script tag then the browser doesn't refresh automatically. The script tag from live server doesn't get injected. image Removing the script tags just works fine.

Software details