How do I add JavaScript to a webpage?

How do I add JavaScript to a webpage?

To insert JavaScript into a web page, use the <script> tag.  The older method used the type or language attributes. This is no longer required as JavaScript is now the default scripting language inside the browser.

Option: 1 (Old Way)
<script language="javascript">
// Javascript code here
</script>
Option 2: (New Way / Shorthand)
<script>
// Javascript code here
</script>
Option 3: Load An External JavaScript File
<script type="text/javascript" src="script.js"> </script>
Scripts can be placed in external files. This is considered best practice as it keeps HTML and JS separate. This is known as separation of concerns. You can do this by keeping your code in a .js file.
Option 3: Load An External JavaScript File
<noscript>
Please Enable Javascript to View This Page Properly!
</noscript>

How do I add JavaScript to a wordpress website?

To add JavaScript to a WordPress website with a plugin download and install the HFCM Plugin. Stands for Header Footer Code Manager. With this plugin you can add site wide or page specific JavaScript code to the header or footer of your wordpress website. It has a lot of handy features including one that will allow you to disable code from one place, use short codes, and add code to just the mobile or desktop versions of your website.

Add JavaScript To A Webpage

Facebook Video