Have you tried just doing $.getScript(script); instead of $("head").append('<script>$.getScript("' + script + '");
$.getScript(script);
$("head").append('<script>$.getScript("' + script + '");