I am creating a library and I want to include jQuery to a user's HTML file if it wasn't included it.
There were some suggestions to do it in the link below:
However, I don't know why it is not working.
Here are the HTML and .js codes:
document.head.innerHTML += "<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script>";
<!DOCTYPE html>
<html>
<head>
<script src="mydebugger.js"></script>
</head>
<body>
<div></div>
<script>
$("div").html("Hi");
console.log(document);
</script>
</body>
</html>
You can see via the console that the <script>
is added to <head>
but it just won't work.
Please consider, I can only add jQuery from the .js file and I cannot add it directly into the HTML file.