I have a bug where the javascript 'load' event is not firing. This only happens when I navigate to code that goes through php however when I navigate to an html file it works fine.
'load' Event in the browser DOES trigger
test.html
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script>
// Show all events that have fired
Object.keys(window).forEach(key => {
if (/^on/.test(key)) {
window.addEventListener(key.slice(2), event => {
console.log(event);
});
}
});
</script>
</head>
<body>
</body>
</html>
'load' Event in the browser NEVER fires
app.blade.php
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{{ config('app.name', 'Laravel') }}</title>
{{-- Fonts --}}
<link rel="stylesheet" href="https://rsms.me/inter/inter.css">
{{-- Styles --}}
<link href="{{ mix('/css/app.css') }}" rel="stylesheet" />
{{-- Scripts --}}
@routes
<script src="{{ mix('/js/app.js') }}" defer></script>
<script>
// Show all events that have fired
Object.keys(window).forEach(key => {
if (/^on/.test(key)) {
window.addEventListener(key.slice(2), event => {
console.log(event);
});
}
});
</script>
</head>
<body>
@inertia
</body>
</html>
I use laravel sail in WSL2.
Things I've tried:
This ended out being a conflict with an IPV6 address.
I listed the processes running on IPv4 and IPv6 and spotted both of these protocols were attempting to use localhost on port 80.
I ran the kill command on the IPv6 process and the browser started behaving correctly.