jquery include js file code example

Example 1: include jquery

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

Example 2: html include jquery

<!-- Wrap inside the head tag -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

Example 3: how to import jquery in js file

var script = document.createElement('script');
script.src = 'https://code.jquery.com/jquery-3.4.1.min.js';
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);

Example 4: html how to add jquery

<!--You can insert Jquery into HTML with the <script> tag in the <head>-->
<!--Insert the next line of code into your <head> tags.-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <!-- jquery (help with javascript) -->

Example 5: jquery import js file

$.getScript('ajax/test.js', function() {
    alert('Load was performed.');
});

Example 6: js jquery include external script

// jQuery
$.getScript('/path/to/imported/script.js', function()
{
    // script is now loaded and executed.
    // put your dependent JS here.
});