The Browser Wars... Never again.
To understand the difference between an interpreted and a compiled language, imagine two stage actors. The first actor, the compiled actor, she sits down and reads her script over many times, committing it perfectly to memory. She makes sure that there are no typos, she checks that all the pages are there and in order, and she probably also refuses to speak out-of-character for an entire year. The interpreted actor, on the other hand, he doesn’t so much as glance at the script until opening night, and even then, he brings it out on stage with him. If one of the pages happens to be missing, he would run off of the stage, weeping uncontrollably.
So a compiled program is verified before it is run, shaking out all the errors ahead of time. Whereas an interpreted language just sorts of does it live.
Developers could now learn a single language to use for both front end and back end programming. This also allows for code to be shared across environments, all that hard work you did on your server doesn't have to be reimplemented from scratch in the browser.
In the last several years, the lessons learned from building server-side frameworks have been ported to the browser. Now we've got access to everything from light templates for structuring code to full-featured frameworks for generating the whole page. These frameworks help you organize your code and build single-page web apps which never have to retrieve a full HTML page from the server after the initial page load.
<script> alert( "Hello World!" ); </script>
src option to a
<script> tag. It's most common to put this into the
<head> tag of the HTML document:
Unfortunately, this will run the script before the page is fully loaded. If you need to rely on the DOM being constructed, you can either use some special functions we'll talk about later (like
$(document).ready()) or just put it right before the closing
<body> tag, which accomplishes the same thing:
<html> ... <body> ... <script> // The DOM will be loaded by now alert("Hello, World!") </script> </body> </html>
...or you can work with an online editor like JS Bin:
The next several lessons will dive into the syntax so you can see what exactly this new beast is made of. Once you get up to speed on the basics, you'll get a chance to start using it to solve problems and messing with the DOM to your heart's content.