In this article, we are going to see , how to load script dynamically with versioning
var script = document.createElement("script");
script.src = `https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js?v=${(new Date()).getTime()}`; //you can put your local script also
script.onload=callback;
document.body.appendChild(script);
//or you can create function
function addScript (src) {
var script = document.createElement("script");
script.src = `${src}?v=${(new Date()).getTime()}` //here is src dynamic versioning
script.onload=callback;
document.body.appendChild(script);
return script;
}
0 Comments
if you have any doubts , please let me know