I want to load js files dynamically with different names avoiding cache. Now I am doing with PHP but I can't use it in a new project.
<?php echo '<script src="lib/jquery/jquery.min.js?v='.round(microtime(true)).'"></script>';?>
I want to load js files dynamically with different names avoiding cache. Now I am doing with PHP but I can't use it in a new project.
<?php echo '<script src="lib/jquery/jquery.min.js?v='.round(microtime(true)).'"></script>';?>
This works! I create the script object with HTML. Then I can dynamically assign the name and a version timestamp parameter.
<script id="myScript"></script>
<script>
var microTime = Date.now();
var myVar = "myJsFile";
var myUrl = myVar+'.js' + '?v=' + microTime;
myScript.src = myUrl;
</script>