DOM Enlightenment. Cody Lindley
Читать

DOM Enlightenment. Cody Lindley

I make websites. Sometimes I make music. Over the years, I’ve noticed an interesting pattern of behavior from some musicians—often self-taught—who think of themselves as creative types: they display an aversion to learning any music theory. The logic, they say, is that knowing the theory behind music will somehow constrain their creative abilities. I’ve never understood that logic (and I secretly believe that it’s a retroactive excuse for a lack of discipline). To my mind, I just don’t see how any kind of knowledge or enlightenment could be a bad thing.Alas, I have seen the same kind of logic at work in the world of web design. There are designers who not only don’t know how to write markup and CSS, they actively refuse to learn.Again, they cite the fear of somehow being constrained by this knowledge (and again, I believe that’s a self-justifying excuse). In the world of front-end development, that attitude is fortunately far less prevalent. Most web devs understand that there’s always more to learn.But even amongst devel‐ opers who have an encyclopediac knowledge of HTML and CSS, there is often a knowl‐ edge gap when it comes to the Document Object Model. That’s understandable. You don’t need to understand the inner workings of the DOM if you’re using a library like jQuery.The whole point of JavaScript libraries is to abstract away the browser’s internal API and provide a different, better API instead. Nonetheless, I think that many front-end devs have a feeling that they should know what’s going on under the hood.That’s the natural reaction of a good geek when pre‐ sented with a system they’re expected to work with. Now, thanks to DOM Enlighten‐ ment, they can scratch that natural itch.Douglas Crockford gave us a map to understand the inner workings of the JavaScript language in his book JavaScript: The Good Parts. Now Cody Lindley has given us the corresponding map for the Document Object Model.Armed with this map, you’ll gain the knowledge required to navigate the passageways and tunnels of the DOM.