How to include external Javascript files

Using tag <script> and SRC attributes, we can include one or more external Javascript files on HTML pages.
The tag for including external javascript files <script> can be placed anywhere within the <html> </html> tag.

syntax:

<script type="text/javascript" src="filename.js"></script>

Example:

<script type="text/javascript" src="myJavascript.js"></script>



How to include jQuery library

Using a <script> tag with an SRC attribute, Jquery libraries can be imported, either downloaded or included with links from hosted CDNs.

Example with downloaded jquery library:

<script src='jquery-3.2.1.min.js'></script>



Example jQuery CDN:

<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>



Example Google CDN:

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



Example Microsoft CDN:

<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"></script>








Privacy Policy