DEV Community

Use Resource Bundles Now -- A Static Web Server

Resource Bundles is a new proposal regarding the problem of nested resource loading on the web. HTTP/2 Server Push previously tried to solve the problem without success; Resource Bundles is the next iteration of the attempt to push the web to the era of native ES Modules.

In the Resource Bundles era, bundlers like webpack would emit a Resource Bundle instead of a big JavaScript file. Browsers would natively understand Resource Bundles.

A resource bundle is simply a set of multiple resources. A resource is a pair of raw payload and all HTTP headers for that payload, identified by URLs. In addition to a resource bundle, bundlers would also emit a β€œmanifest”, a dependency graph between resources in the resource bundle. Thanks to this, browsers can download all the resources needed by one request.

By browsers natively understanding Resource Bundles, efficient caching of resources is enabled too. Browsers can choose to request a subset of whole resource bundle, only requesting ones that aren't cached yet. The server that serves resource bundles would also support subsetting.

Although Resource Bundles are in its very early stage and few of its details are decided, you can try using Resource Bundles now. The author created a tools for parsing and serializing Resource Bundles based on the current draft of the proposal, as well as a CLI for inspecting and creating Resource Bundles and a static server for serving resources from a Resource Bundle.

The last one, static server, is actually going aside from the main purpose of Resource Bundles, and is described as β€œother uses” in the proposal. As resource bundles already include HTTP headers for each resource, configuring a static web server would be made extremely easy with Resource Bundles. This means that, in a future, bundler config would include HTTP headers for generated resources.

Finally, you can try that static server now! Try @resourcebundles/static-server.

Disclaimer: this work is totally unofficial.

Top comments (0)