The unobtrusive javaScript programming paradigm
Unobtrusive JavaScript is an approach to web programming that supports separation of behaviour (JavaScript code), structure (HTML code) and presentation (CSS code).According to this programming paradigm, to accomplish separation is best to write all your JavaScript in an external file and embed it in HTML document using a
<script> element with src attribute.
The <script> element is synchronous by default
Let's examin how the <script> element allow you to insert javascript in a HTML document.<script src="scripts/javascript_app.js"> </script> <!--synchronous script-->
When JavaScript engines encounters a <script> element, they stop parsing HTML to download and interpreter the JS file, then they resume parsing and rendering HTML.
The <script> element has two important attribute: HTML 4.1 defines the async attribute and HTML5 introduces the defer attribute. These two attributes cause scripts to be executed differently, in browsers supporting them.