How can I access modules in my js file:
<script type="text/javascript" src="script.js?modules=test,cookie"></script>
give an ID to your script tag
<script type="text/javascript" src="script.js?modules=test,cookie" id='YOURID'></script>
then in your js file use :
jsSrc = document.getElementById("YOURID").src;
var jsQry = jsSrc.substr(jsSrc.indexOf("?"));
a super hacky way to do it would be to give your script tag an id attribute and then access it from within the script itself, pulling out and parsing the src attribute :)
<script id="myscript" src="script.js?modules=a,b"></script>
in jquery you could do:
$(function(){
var modules = $('#myscript').attr('src').split('=')[1].split(',');
});
like i said, super hacky, but could work!
Assuming you mean:
How can I read the query string used to load my JS file in my JS?
Then the most reliable way is to generate the JS server side and include the data that way.
For example:
<?php
header('Content-Type: application/javascript');
echo 'var modules = ' . json_encode($_GET['modules']);
?>
A less reliable, but entirely client side, method is to find the last script element in the document and parse the URI.
var scripts = document.getElementsByTagName('script');
var myScript = scripts[scripts.length - 1];
var uri = myScript.src;
// and so on