Hi Owen,
No worries, I fully understand and respect your need to code in private. I recently started using ss.load.code() to load some code on demand, and I have some ideas:
1. Have you considered adding a similar capability for on-demand template loading?
2. It would be nice to be able to specify an array of files or folders to all load asynchronously. For example, page A and B both have a box X. When page A is requested, I'd like to be able to do something like:
ss.load(
code: ['/demand/page-a', '/demand/box-x', '/demand/dependency-i.coffee']
tmpl: ['/demand/page-a', '/demand/box-x', '/demand/dependency-j.jade', '/demand/dependency-k.jade']
, ->
# gets called after all dependencies are loaded
)
where, for instance, the box X assets may already be loaded from previously viewing page B.
3. Having a common folder to put demand-loaded code and templates would eliminate the repetition of '/demand/' above:
ss.load(
code: ['page-a', 'box-x', 'dependency-i.coffee']
tmpl: ['page-a', 'box-x', 'dependency-j.jade', 'dependency-k.jade']
, ->
# gets called after all dependencies are loaded
)
and it's similar to ss.client.define().
4. It would be great if the namespace was relative to that common 'code/demand/' folder. So 'code/demand/page-a/model.coffee' would be required with:
require('/page-a/model')
regardless of whether it was loaded as 'page-a' or 'page-a/model.coffee'.
5. How about support for minifying (and gzipping and RAM caching) on-demand code in production mode? It would need to happen only on the first request for the file and be erased when the other packed assets are erased. A possible path suggestion for these assets would be something like:
static/assets/demand/[random number]-code/[subfolders]/[filename].js
static/assets/demand/[random number]-tmpl/[subfolders]/[filename].html
where the random number could be the same one as for the other packed asset filenames, and the subfolder and filenames are the same as those of the original files.
Dave