Adding Javascript to the page

Adding Javascript to the page

js likhna toh seekh jaoge ,usko page se link krna toh seekhlo

There are 2 ways to add your javascript

  1. Inline Javascript or use script tag

  2. External Javascript

    Inline Javascript

    In internal js, we use a script tag and inside the script tag, we write js code.

     <script>
     alert("hello world");
     </script>
    

    External Javascript

    in this, we make a separate js file where all the js code is written and we attach that file using the "src" (source) attribute in the script tag.

    Will the code inside the script tag run after adding an external js file?

    NO ! the code inside the script tag will be ignored when the external js file is added.

     <script src="file location">
     //content inside this will be ignored
     </script>