Getting Setup
- Open your favourite texteditor.
- Create an empty file and save it as
index.html
. - Open a browser. I recommend, Chrome, Mozilla, or Edge.
- Open the path:
file:///absolute/path/to/your/file
, voila, a basic web page. - Return to your texteditor and add some basic
HTML
scaffolding. eg.
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>My first JS!</title>
</head>
<body>
</body>
</html>
- There are two main ways to include a script in our
HTML
.- Directly inline
- Or externally. Let’s opt for the external option – add the line:
<!-- just before the body closing tag -->
<script src="script.js"></script>
- Create a new file in the same directory with your texteditor and call it script.js. Now we’re ready to roll!