JavaScript import maps are now supported cross-browser
It&#x27;s really wild seeing the tremendous amount of work being put in to ESM just to come up with a solution that still isn&#x27;t as fast, secure, or ergonomic as bundling.<p>1. Import maps are basically a compile-time feature. I thought the point of all of this was to not have to have toolchains?<p>2. Imports <i>significantly</i> lag behind &quot;old school&quot; scripts in security. You can&#x27;t use integrity hashes with them, and yet most the examples you see are about importing random scripts from all over the web. This is actually hilariously related to point (1), since you can only escape the realization that this is a feature a compiler is supposed to spit out if you direct the imports to some third party resource. So in order to contrive a situation where you would manually craft an import map, they are forced to show an example that is less secure than the stuff that has worked in every browser for 10 years.<p>3. Not directly related to import maps, but you&#x27;ll probably end up using them together: in order to attempt to achieve similar performance to just bundling your code, the amazing solution we&#x27;ve come up with is to... put a &lt;link rel=&quot;modulepreload&quot;&gt; tag in your head element for each script you want to be fetched immediately. Yes, so much better than the ridiculous old method of using a script tag for each script. Now you just use a link tag for each script instead. I&#x27;m sure someone will tell you that this is better because you don&#x27;t <i>have</i> to do that. Yes, yes, so much better that the default behavior of script loading is slow unless you go read about a bunch of &quot;tips and tricks&quot; to get it working with reasonable performance.<p>It&#x27;s always great to take one concept like &quot;importing a script&quot; and turn it in a an entire ecosystem of terminology that spans languages and platforms, custom JavaScript syntax for the imports themselves, a set of different HTML tags for actually getting them into your page (script, link, etc.), and JSON for mapping names to URLs. Great. Super simple.<p>ESM has always suffered from a weird shifting argument. Whenever you point out that the performance and security isn&#x27;t great, all of a sudden it&#x27;s a developer ergonomics feature, not meant to be for production. Then when you point you the ergonomics suck (like not being able to do bare imports), you&#x27;re told you should be using it in tandem with a toolchain that auto-generates import maps or something. So what&#x27;s the benefit? I already had a tool that could do that, and it worked in every browser and didn&#x27;t ignore the the security advancements we made 10 years ago.