There are no conditional top level imports, but you can call import("thing") which gives you a promise for the module.
I am not affiliated with Vite in any way, I just really like it for vanilla web dev.
The only thing to note for purists, it creates .vite folder which you have to ignore.
Not meaning to pick at anything here, but to me web dev necessarily requires knowledge and configuration of a web server.
What's being sent to the browser in a production setting is an HTTP message, not just the web content.
Many features of a non-trivial web page/app will at least require HTTP headers to be set. The "file://" protocol handles this by mocking the full HTTP response for you in the browser, but any deviation from that response on an actual web server has the potential to break your page. I wouldn't rely on opening files directly.
> So you can't open your index.html over the file:// protocol.
It's not a dealbreaker but that is a significant inconvenience for me. I do local development over file:// a lot.
One thing I'm wondering about is dynamic loading of modules. Say my main.js should only load extra.js under certain circumstances. How does that look?