Description
IDOM_WEB_MODULES_DIR
contains JS modules that are dynamically added at runtime. Since JS files are typically loaded statically, it would be nice if we could improve how quickly these files can be accessed. There are three ways to do that:
- Implement a management command for collecting these static files ahead of time.
- Make the view accessing the files
async
to avoid blocking while waiting on the file system - Cache this view using Django's cache framework.
Notes
To implement the management command we could trace over all the templates and look for idom_component
template tag nodes in order to figure out what modules to import so that we can trigger the collection of the JS files into IDOM_WEB_MODULES_DIR
. Then once they've been collected those files can be copied into a permanent static location.
To do this we can take inspiration from the django compressor library which takes a similar approach. See the COMPRESS_OFFLINE
setting to figure out how they're doing it. Also the compressor.offiline
module contains uniform interfaces for parsing template syntax for Django and Jinja that we might want to copy (with the latest LICENSE, what to do about AUTHORS
file?).
Conversation originated from: this comment