I want to load a JS and his behaviour should differ depending of one parameter. I thought one of the ways to do this could be:
<script src="script.js?type=a" type="text/javascript"></script>
<script src="script.js?type=b" type="text/javascript"></script>
...
Then, I would obtain the parameter using regex, like:
function getURLParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
}
(above function from here).
However, I'm not sure if this is the best approach for this. Do you suggest any other way to do this, like, loading global variables inside the <script></script>
and then read them from the JS?