file_create_url() equivalent in a javascript file?
CDN has already done its magic by the time the JavaScript file has been prepared for output, and there are no AJAX callbacks allowing it to do its magic from the JS file itself.

If you do know ahead the name of the scripts you might load (or you can iterate from your theme or module) then the trick is to inject those paths as variables directly in your theme using inline JavaScript. For example, from your module or your theme's hook_html_head_alter method in template.php, to add one file (the method would be the same for a list of files, but an array would best be used):

drupal_add_js('var my_js_file_1 = "' . file_create_url(drupal_get_path('theme', 'my_theme') . '/js/file_1.js') . '";' , 'inline');


then you can call

$.getScript(my_js_file_1);


in your code.

The magic is done through the file_create_url, which is what the CDN module processes.