How to use the same JavaScript in multiple content pages?

JavascriptWeb DevelopmentFront End Technology

To use the same JavaScript in more than one page, add the js code in an external JavaScript file. Let’s say the following demo.js is our external JavaScript file −

function display() {
   alert("Hello World!");

Now add the external JavaScript file to the following HTML web page. In the same way, you can add it to multiple content page.

         <input type="button" value="Result" onclick="display()"/>
      <script src="demo.js">
Updated on 13-Jun-2020 06:45:08