Search code examples
javascripthtml

Firefox this page has no sources


I'm working on a JavaScript game and it works as intended in Chrome and Safari. However, in Firefox, the page doesn't load any scripts, and the debugger is empty. I'm not seeing any errors at all. This is the entirety of the html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <canvas id="canvas"></canvas>
    <script type="module" src="foo.js"></script>
    <script type="module" src="bar.js"></script>
    <script type="module" src="baz.js"></script>
    <script type="module" src="qux.js"></script>
    <script type="module" src="foobar.js"></script>
    <script type="module" src="bazqux.js"></script>
</body>
</html>

UPDATE: Some added context for future readers: per Roko C. Buljan's answer, it turns out ES6 modules are not on by default in FireFox at the time of writing. That was the issue.


Solution

  • You're using module features not openly available in Firefox. To enable them you could go to about:config and enable them under dom.moduleScripts.enabled setting its Value to true

    enter image description here

    Meanwhile you could use a polyfill like this or use build tools that will compile your modules into a single ES5-backed production-ready file.

    Some indepth readings:

    https://html.spec.whatwg.org/multipage/webappapis.html#integration-with-the-javascript-module-system
    https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script https://jakearchibald.com/2017/es-modules-in-browsers/
    https://medium.com/webpack/the-state-of-javascript-modules-4636d1774358