On-demand (code splitting) in Clojurescript

No, not at all. This is something you’d be doing on your server serving the initial HTML. The client side scripts already know about the hashes and will already load all the correct files. The CLJS side doesn’t need to do anything with the manifest ever. If it does it is doing something incorrectly.

The server however can just load the manifest and emit the proper script tag since it gets the hashed name out of that. So instead of <script src="/js/main.js"> it can generate <script src="/js/main.asdfakjlsdfa.js">. How that looks is entirely dependent on what your server looks like. It is maybe a couple lines of code for a regular CLJ server.

2 Likes