doesn't work?", "text": "<p>I'm working on a project, and I didn't understand why a call to external script doesn't work.</p>\n\n<p>Then I just did a extremely simple page html which includes a script alert, as you can see below... Can you tell me what's the problem ? I believe the problem is not the code, but what else can it be?</p>\n\n<p>My browser is a recent Chrome, and my OS is Ubuntu.\nMy HTML file is index.html :</p>\n\n<pre class="prettyprint"><code><!DOCTYPE html>\n<html>\n<head>\n<meta charset="utf-8">\n<meta http-equiv="X-UA-Compatible" content="IE=edge">\n<title>MyPage</title>\n</head>\n<body>\n <p>Blablabla</p>\n <script type="text/javascript" src="/script.js"></script>\n</body>\n</html>\n</code></pre>\n\n<p>The Javascript file is script.js in the same folder:</p>\n\n<pre class="prettyprint"><code><script type="text/javascript">\nalert('Hey');\n</script>\n</code></pre>", "answerCount": 2, "upvoteCount": 500, "dateCreated": "2026-06-28 20:20:06", "dateModified": "2026-06-30 10:45:39", "author": { "type": "Person", "name": "florian" }, "acceptedAnswer": { "@type": "Answer", "text": "<p>Paths starting with <code>/</code> are absolute paths. If the script and the HTML page are in the same directory, the script's path is simply "script.js":</p>\n\n<pre class="prettyprint"><code><script type="text/javascript" src="script.js"></script>\n<!-- Here --------------------------^ -->\n</code></pre>", "upvoteCount": 189, "url": "https://exchangetuts.com/why-a-simple-script-src-script-doesnt-work-1767991803552350#answer-1782850806198066", "dateCreated": "2026-06-29 20:45:39", "dateModified": "2026-06-30 10:45:39", "author": { "type": "Person", "name": "Mureinik" } }, "suggestedAnswer": [ { "@type": "Answer", "text": "<p>If the file is in the same folder remove the "/" from script.js</p>\n\n<p><code><script type="text/javascript" src="script.js"></script></code></p>\n\n<p>Also if the js file has the script tags remove them.</p>\n\n<p>If you want the alert when the doc is ready, consider doing something like:</p>\n\n<pre class="prettyprint"><code>document.addEventListener("DOMContentLoaded", function(event) { \n alert('Hey')\n});\n</code></pre>", "upvoteCount": 42, "url": "https://exchangetuts.com/why-a-simple-script-src-script-doesnt-work-1767991803552350#answer-1782850806204617", "dateCreated": "2026-06-29 20:45:39", "dateModified": "2026-06-30 08:45:39", "author": { "type": "Person", "name": "FutoRicky" } } ] } }