Member-only story

ES6 modules in the browser: are they ready yet?

David Gilbertson
7 min readMar 5, 2020

--

Have you heard about ES6 modules in the browser? They’re like ES6 modules, but in the browser.

For those not in the know, this is what they look like:

They’ve been around for years, and maybe you’re wondering if you should dip your toes in. Well, I’ve been using them for the last month or so on a side-project, and have come the conclusion that …

Suspense!

First things first, the browser support: as I write this at the start of 2020, it’s a pretty respectable 90%.

I’m quite happy with 90% coverage (I don’t like 10% of people), but maybe you want to be more responsible. Even then, if your project doesn’t aim to support IE or UC or mini, that support stat gets pretty close to 100% of your target audience.

But browser support is only the beginning. In this post, I’ll aim to answer the three questions that I had at the beginning of my journey:

  • Is there any benefit to using modules in the browser?
  • Are there any downsides?
  • I’m certain I had a third question but I don’t recall now.

Let’s get into it …

What are the benefits?

It’s vanilla JavaScript! No build pipeline, no 400 line Webpack config, no Babel, no plugins and presets and 45 other npm modules to install. It’s just you and your code, no muss, no fuss.

There’s something refreshing about writing code that will actually be run in the browser, as authored. It might take a wee bit more effort, but it’s really quite satisfying. It’s like driving a manual car or maintaining your own peep of chickens (call me crazy, but an egg tastes better if you eat it while looking its mother in the eye).

--

--

David Gilbertson
David Gilbertson

Responses (9)

Write a response