Douglas Crockford's JavaScript Video 4 - AJAX

These videos are remarkable in the packed world of IT training videos in that they are clear and enjoyable to watch. The fourth instalment is about Ajax, but goes into plenty of detail that I didn't know about where the DOM came from and some info about the famous browser wars. Here are my notes so that you can see what is in there before you invest 90 minutes.

Markup languages

RUNOFF
GML - generalized markup language
SGML
HTML - simplified SGML
Latex

Angle brackets came from Scribe.

HTML

Does not fail on errors - allowed innovation. Otherwise the web would have frozen.
2 types of outlines - H1 - not nested and p type which are. Yuk.

CSS

Not modular - clashes can wreck your page.
difficult to manage selectors - classitis and iditis.
None of the browser vendors ever got it implemented!

The DOM

Brendan Eich - Netscape

Browser workflow

url -> Fetch -> cache  -> Parse -> Tree ->  Flow -> display list ->  Paint -> pixels

Comments around script tags just protects users of ancient browsers from seeing the script. Don't bother with this.

document.write

Very bad. Don't do it.

For performance improvement of scripts


  • minify
  • gzip
  • Reduce number of script files (concat at deploy)
  • Use something like Chrome PageSpeed to test


Javascript uses camel case for style properties. CSS uses hyphens - incompatible with JS - in fact incompatible with most languages. Done on purpose. Source of annoying bugs.

InnerHTML 

Nice and fast, but dangerous. Developed by ms - all browsers support it.

Always err on the side of understanding and clean code over performance unless performance is a serious problem.


Events

Bubble up through the DOM - use stopPropagation to deal with this.
Allows attaching of a single event handler to a container. The container then dispatches the event to the appropriate element. Faster to set up.

Use good speed testing tools - Chrome best.

Server vs browser

Neither side should dominate. A balance is the best. The server is not a filesystem and the browser is not a dope that just displays returned content.




Comments

Popular posts from this blog

Building a choropleth map for Irish agricultural data

Early Stopping with Keras

AutoCompleteTextView backed with data from SQLite in Android