Google just released Chrome version 80 on Tuesday, February 4, 2020. I personally waited for this specific release for over one year and it feels like the most important major release in a very long time.

What is a Javascript module?

As soon as you are using the ES6+ class system, you will most likely automatically work with JS modules:

If you stick to the “1 class per file” design pattern, you will most likely want to import the base class which you extend. You will also most likely want to export the new class at the end of your file. As soon as you are using an import or export statement, your file is already considered to be a JS module.

Can JS modules run directly inside a browser?

Inside the main thread, this is already possible in Chrome, Firefox & Safari for a long time. Using JS modules inside a web worker was already possible in Chrome for quite some time as well, but hidden behind an experimental flag. Now with Chrome v80, it is finally possible out of the box.

Side note: this widens the gap between Chrome & other browsers by a long shot. Sadly the FF & Safari dev teams have related tickets open for several years, without any priority.

How to create a worker from a JS module?

It is up to you if you want to name your js module files .mjs or just .js, adding type: ‘module’ is the key to do it.

What is the advantage to use JS modules directly inside the browser?

You can create well structured apps and run them inside the browser without the need for any JS related build processes. Meaning: you can change the source code and just reload the browser page, without the need for webkit watching the file-changes & hot module replacements.

Is there already a web workers driven JS UI framework out there?

Yes, neo.mjs got released to the public on November 23rd, 2019.

Repository:

Online Examples:

What is coming next?

If you did look close at the release schedule, you might have noticed that Chrome v81 is scheduled for March 17th. This version will include JS module support for shared workers. This is the key for crafting multi browser window apps (e.g. apps which can run on multiple screens).

Best regards & happy coding,

Tobias