New Perspectives On Web Design

(C. Jardin) #1

CHAPTER 3 The Vanilla Web Diet


and egg problem of standards support by demanding that browser makers
add the support when we can show our products are ready for it.
Every good Web solution works by leaving the right tasks to the right
technology. We often get too excited about our specialisms and want
everything to be possible in the one we favor. A band creates music when
its members play the instruments that they want to play. Very few people
can play the drums, guitar and trombone, and sing — none can at the same
time. Pick and choose, don’t try to replace.

aSK The “if” QueSTion
Whatever you do should be wrapped in an “if”, so only environments that can apply
what you want do so.
Using “if” is a powerful tool, both in conversations and coding. Good
coding is defensive — it tests the depth of the water before diving in. Our
solutions should not just assume that a certain user has what’s needed to
consume the content we give them.
Wrapping the loading of content in test cases is an incredibly powerful
way to achieve the most enjoyable experience for different users — we’ll
come back to that later.
However, “if” can be used for much more. You can ask the current
environment about its capabilities before applying a certain functionality.
You can stop the browser from trying to run whole blocks of JavaScript by
first asking if it can do even the simplest things required. The less code we
force our browsers to parse, the better their performance will be. Why read
a whole book in Icelandic to a friend without asking if they understand the
language in the first place?
Sometimes it is necessary to apply some trickery to avoid very bad
experiences. HTML5 video is one of those examples. You might have seen
the following demo code in a few places.
Free download pdf