How to combine dynamically created assets

CombineAssets - October CMS this class handles files that physically present in the file server, what if I want to combine PHP variables (that contain javascript) created on the fly in one single javascript file?
An example might be: I’m creating a dynamic js file made up of multiple outputs and want to combine and minize them into a physical file .js in storage to be reused without reprocessing it.


Hi @sandros87

You should just be able to pass this through \JSMin::minify($contents); to minify the contents.

1 Like

Is CombineAssets linked to the Cache API?

Cache allows to cache content with a custom ID and you can “query” the Cache to check if that content still exists, however how do you do the same with CombineAssets if the part of the content you provided while caching does not physically exist on the server as an asset (\JSMin)?

That’s true. We have a separate need to feed contents directly in to the minifier, so we should add this ability soon.

So as of now for everything to work correctly (aka avoid returning empty combined file or errors) files actually need to exists in the file-system, correct?

By that I mean

  1. to cache combined files
  2. to recombine and recache them if they’ve been modified
    all this done automatically

Also there’s a mistake in the doc I think, here CombineAssets - October CMS combineToFile is not a static method

Correct. Combined files are stored locally but always delivered through the web server. Eventually we will switch this to static files.