Introduction
- JavaScript is the one of the most popular programming language.
- JavaScript and Java are completely different languages, both in concept and design.
- HTML is used to define the content of web pages
- CSS is used to specify the layout of web pages
- JavaScript is used to program the behavior of web pages
ECMAScript
- ECMAScript is a JavaScript standard/specification intended to ensure the interoperability of web pages across different browsers.
- It is standardized by ECMA International
Versions
- The Original JavaScript ES1 ES2 ES3 (1997-1999)
- The First Main Revision ES5 (2009)
- The Second Revision ES6 (2015)
- Yearly Revision from 2016
Internal JavaScript
- Scripts can be placed in the
<body>
, or in the<head>
section of an HTML page, or in both. - Placing scripts at the bottom of the
<body>
element improves the display speed, because script interpretation slows down the display. -
- Old JavaScript examples may use a type attribute:
<script type="text/javascript">
. The type attribute is not required.
- Old JavaScript examples may use a type attribute:
- JavaScript is the default scripting language in HTML.
- JavaScript code is inserted between
<script>
and</script>
tags.
External JavaScript
- Scripts can also be placed in external files
- External scripts cannot contain
<script>
tags. - JavaScript files have the file extension .js.
- It separates HTML and code
- It makes HTML and JavaScript easier to read and maintain
- Cached JavaScript files can speed up page loads.
<script src="index.js"></script>