Eloquent Javascript Chapter 12: JavaScript and the browser

Source: http://eloquentjavascript.net/12_browser.html

  • JavaScript would have been useless and unknown without Web browsers
  • Internet is based on networks of computers communicating using common network protocols (esp. TCP, which provides an abstraction of the network)
    • WWW is a bunch of machines communicating using HTTP on port 80
  • HTML is the webpage document format made up of content and tags to structure the content (begin with <!doctype html>)
    • Very error tolerant — browser reconstructs tags that are missing in a standardized way
    • Don’t omit doctype declaration since browsers are funny about how they interpret them
  • The <script> tag lets you include a piece of JavaScript in a webpage
    • Unless otherwise specified, will run as soon as the <script> tag is parsed
    • Use src attribute to fetch script file from a URL similar to how you use href to point to a CSS style sheet in a <link>  tag
    • Must always be closed with </script>
  • Some attributes can contain a JavaScript program (e.g. <button> with onclick attribute)
  • Browser generally tries to sandbox JavaScript to limit the amount of damage a bad program can do, but it’s always an arms race
  • Early 2000s had browser devs unilaterally inventing new Web features based on browser popularity
    • Firefox and Chrome eventually took over most market share, and their (better) code standards are responsible for the current interoperability situation
    • Beware outdated browsers that government or other enterprises are forced to keep running (this is a topic that will not be covered in this doc)

Leave a Reply

Your email address will not be published. Required fields are marked *