IMY 110
JAVASCRIPT
WHAT IS JAVASCRIPT
WHAT
● A client-side programming language
● It runs in the browser and does not need a server
● Used to:
○ Validate forms (client-side)
○ Check if the password is long enough, contains letters etc
○ Create animations and games
○ Show/hide elements
○ Works with powerful HTML5 features (e.g. canvas and geolocation)
○ Search and autocomplete
WHERE DOES IT FIT IN
● Interactivity of a website
HOW TO USE IT
● Script tags: script tags can be anywhere inside the body or head of an
HTML document
○ Insert it before the closing body tag so that the whole page loads
before the JavaScript runs (no errors)
● External script file
SYNTAX
EXTERNAL SCRIPT FILE
● <script src = “script.js”></script>
● To add JavaScript in an external script file (recommended), include the
src attribute inside the <script> tag and leave the tag empty
JAVASCRIPT
WHAT IS JAVASCRIPT
WHAT
● A client-side programming language
● It runs in the browser and does not need a server
● Used to:
○ Validate forms (client-side)
○ Check if the password is long enough, contains letters etc
○ Create animations and games
○ Show/hide elements
○ Works with powerful HTML5 features (e.g. canvas and geolocation)
○ Search and autocomplete
WHERE DOES IT FIT IN
● Interactivity of a website
HOW TO USE IT
● Script tags: script tags can be anywhere inside the body or head of an
HTML document
○ Insert it before the closing body tag so that the whole page loads
before the JavaScript runs (no errors)
● External script file
SYNTAX
EXTERNAL SCRIPT FILE
● <script src = “script.js”></script>
● To add JavaScript in an external script file (recommended), include the
src attribute inside the <script> tag and leave the tag empty