Get .js file options
I have a javascript file that I reference in HTML with standard <script src="foo.js?param"></script>. In the file I want to distinguish, for example. uploading a file using foo.jsfrom foo.js?autoand foo.js?noauto=true, but not if the file is renamed to bar.jsand refers to the same parameter. How can I do this, it is advisable not to use any kind of framework?
Take a look at the scenario approach:
var js = /scriptaculous\.js(\?.*)?$/;
$$('head script[src]').findAll(function(s) {
return s.src.match(js);
}).each(function(s) {
var path = s.src.replace(js, ''),
includes = s.src.match(/\?.*load=([a-z,]*)/);
(includes ? includes[1] : 'builder,effects,dragdrop,controls,slider,sound').split(',').each(
function(include) { Scriptaculous.require(path+include+'.js') });
});
I think it goes through all the elements of the script and finds a link to itself, and then parses that URL.