2 ms·
Files opened from disk can run JS. But you can't do <script src="otherfile.js"> without getting a cross-origin error, even if it's in the same directory. So a
by Dwedit 3y ago
Files opened from disk can run JS. But you can't do <script src="otherfile.js"> without getting a cross-origin error, even if it's in the same directory. So any kind of code organization at all is prohibited.
- cxr 3y ago~/scratch/wrong$ cat ./index.html <!doctype html> <html> <head> <script src="otherfile.js"></script> </head> <body> <p>otherfile.js did not run</p> </body> </html> ~/scratch/wrong$ cat ./otherfile.js window.onload = (() => { document.querySelector("p").textContent = "wrong. (otherfile.js ran)"; });