I know you’ve solved this, but just looking at the code, you’re appending a string to the head of the document, not a script tag.
You’d need to create a script element, then set its attributes and then append that to the document’s head:
const script = document.createElement("script");
script.setAttribute("type", "text/javascript");
script.setAttribute("src", "https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js");
// note that you could use script.type and script.src, but using the setAttribute method is considered better practice
document.head.append(script);