registerScript() to put content in a temp file

Would be nice to have an option/parameter for registerScript() so that it puts the custom code in a file (in assets folder) and includes that file in a view… something like:

registerScript(‘fileid’,’…script code…’,CClientScript::POS_HEAD,CClientScript::POS_FILE);

So with this call the file named ‘fileid’ containing ‘…script code…’ would be included at CClientScript::POS_HEAD

I know there is registerScriptFile() but this option would be for more dynamic script and the resulting HTML source would be cleaner…

what if the JS code changes in every request? will it create the new code and regenerate the file? or will stay untouched?

If we are talking about the resources files, I think there should be a default implementation for combining multiple resources files into a single file, To reduce the number of HTTP requests for resources files. Something that will take all files combine them into one and include only that file in the source, You can event improve that by specifying for each resource if he should be combined with the others or not and if the combined file should be minified for example.

This shouldn’t be too hard to achieve as an extension but i think those options should exists as a default.