Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML script tag greyed out and not loading

enter image description here

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>
like image 674
ivivjcb Avatar asked Sep 02 '25 05:09

ivivjcb


2 Answers

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?

like image 137
lukaszkups Avatar answered Sep 04 '25 21:09

lukaszkups


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>
like image 25
s.kuznetsov Avatar answered Sep 04 '25 20:09

s.kuznetsov