Does preloading of modules make sense?

An easy to implement technique relieving developers of bundling

Marian C.
4 min readOct 22, 2021

JavaScript modules offer enjoyable developer experience. However, it is believed that modules might disappoint exceptionally demanding users on the first-time visit because, in comparison to a single bundle, numerous modules need more time to load.

When a browser load a web application composed of JavaScript modules, it first loads the modules listed in the HTML. Then the browser discovers import statements in the just loaded modules. The browser loads the required modules and again discovers import statements specifying additional modules to load. Eventually, after several loading and parsing iterations, the browser loads independent leaf modules without import statements.

During gradual loading of the entire module dependency tree, waiting for responses from the network takes most of the time. For example, requesting the root module specified in the HTML and waiting to receive it is a waste of the network bandwidth. If all the modules are requested immediately, and not in their hierarchical order, the time spent on loading all the modules will be shorter.

The problem is that the browser does not know in advance what modules it will have to load. Only after loading a module the browser sees its…

--

--

Marian C.
Marian C.

Written by Marian C.

Java, JavaScript and SQL developer. Interested in data collection and visualization.

No responses yet