Dynamically loading JS script
I am getting a parameter from the URL and based on that parameter, I want to load a different JS file. I tried everything I found on the web but I couldn't make it work.
Here is my code:
I have both lines within <head> element. I need this to work locally, not on a server. I can't use Ajax type of solution (I guess). For example, I tried the first 3 solutions on this page but they didn't work for me.
// This line gets the parameter from the URL i.e. mypage.html?var=var1.
<script>var myVar = location.search.split('var=');</script>