Creating JS file on the fly I have a code that generate a big bunch of javascript code and I would like to create a .js file on the fly and include the code in it.

The code would be reconstructed at each cache destruction. The file would be used by all visitors.

Any ideas what I could use to make this possible? Or there's no "drupal way" to do this?

thank's!
I would do this in this way:

function YOUR_MODULE_init(){
    drupal_add_js('path/you/want/to/use/to/include/javascript.js');
}

function YOUR_MODULE_menu() {
    $items = array();
    $items['path/you/want/to/use/to/include/javascript.js'] = array(
        'title' =&gt; 'Generated js',
        'type' =&gt; MENU_NORMAL_ITEM,
        'page callback' =&gt; 'your_function_name'
    );
    return $items;
}

function your_function_name() {
    $js = ... your code that composes js here ... ;
    print $js;
    exit;
}