javascriptjquerybootstrap-dialog

How to include CDN in javascript?


I know how to include CDN in HTML file.

<!DOCTYPE html>
<html>
<head>
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
</body>
</html>

But what I am trying to do is:
I want to include CDN like jquery in my javascript file.

May be what I am trying to do is impossible.
Actually, I want to call BootstrapDialog.Confirm from my javascript file.
So, I want to include required CDN for BootstrapDialog in js file.
Then I can call BootstrapDialog.Confirm.

If my question is not reasonable, forgive me as I am a beginner.


Solution

  • You can do it in Javascript:

    var jQueryScript = document.createElement('script');  
    jQueryScript.setAttribute('src','https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js');
    document.head.appendChild(jQueryScript);