My problem when I am trying to load script dynamically it is becoming async it causing issue when we are trying to use the function in body of html
when i try the XMLHttpRequest to get the data it is sync but it is not getting cached at browser level.
var jsElm = document.createElement("script"); //getting data async
jsElm.type = "application/javascript";
jsElm.src = file;
document.body.appendChild(jsElm);
var xmlhttp=new XMLHttpRequest();//getting data sync but not cached
xmlhttp.send();
I want to know how to load the script which sync and next time load from cache.