Skip to content
techsnow

Introduction

Adding JavaScript

1. External file (best)

<script src="app.js" defer></script>

defer waits until the HTML is ready before running your code, so your script can safely find page elements.

2. Inside a script tag

<script>
  alert("Welcome!");
</script>

3. Running JavaScript outside the browser

Install Node.js from nodejs.org, then run a file from the terminal:

node app.js