The image shows what my code looks like. I have a js file I want to use but for some reason I can't load it.
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{title}}</title>
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@1,300&display=swap" rel="stylesheet">
<link rel="stylesheet" href="/css/style.css">
<script type=""src="/public/js/app.js" defer></script>
</head>
I see couple potential issues here:
#1 Do you see the file in the network tab being loaded? Are you sure the path to the file is 100% correct?
#2 Add space between type=""src="..."
or remove type
property totally (as it's empty anyway)
#3 Do you run this on any local server? Or you open it as a static HTML file in your browser?
You get error "The resource from “localhost:3000/public/js/app.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).", which indicates an empty value for the attribute type=""
. And your webserver cannot determine the js resource type. Add the required attribute, type text/javascript
.
Also, remove the space between the attributes - type=""src="/public/js/app.js"
.
<script type="text/javascript" src="/public/js/app.js" defer></script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With