import script javascript code example

Example 1: import js in html

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

Example 2: include script in html

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

Example 3: linking a script .js

<script type="text/javascript" src="path-to-javascript-file.js"></script>

Example 4: import script html

<html>
  <head>
    <script type="text/javascript" src="/path/to/script.js"></script>
    ...

Example 5: how to enter javascript in html

<script type="text/javascript">
  alert("This alert box was called with the onload event");
</script>

Example 6: javascript using another js file

// module.js
export function hello() {
  return "Hello";
}

// main.js
import {hello} from 'module'; // or './module'
let val = hello(); // val is "Hello";

Tags:

Html Example