Douglas Crockford: An Inconvenient API - The Theory of the DOM

YUI Library · 107K views · 2011 · 1:18:08

Open on YouTube

Web developmentProgramming language designtalkdated

Why Stack Overflow recommends it

Stack Overflow users link it when explaining what the DOM is and when advising against practices like document.write, script type attributes and poor script placement.

Recommended by 1 people across 1 different months, 2012 to 2016.

What it is

A 2006 internal Yahoo! tech talk in which Douglas Crockford walks through the history and design problems of the browser DOM, the API frontend engineers use to manipulate pages. It covers topics such as script and link placement, document.write, and redundant script attributes.

What people said

Recommends Useless Code · 2015-04 · Stack Overflow · on “Hide one form when other button is clicked on (two buttons, two forms) (PHP/HTML/Javascript)”

@wuv1 Document Object Model [LINK] , it is the API you use to access and manipulate elements on the page. If you are interested in more info about how the DOM works and some history on how it came to be, Douglas Crockford's talk An Inconvenient API - The Theory of the DOM [this video] is quite interesting.

Cites tereško · 2012-08 · Stack Overflow · on “How to use AJAX in an MVC - php Blog? - adding comments dynamically”

Before you even try to learn how to use MVC, you should learn how to write semantic HTML and unobtrusive JavaScript! Judging by posts.php files, you really have no clue what you are doing. I would recommend reading everything from this page [LINK] . It will contains a lot of very good materials about HTML. Then watch this lecture [this video] and then watch everything on [LINK] . Also i would advise you read Eloquent Javascript [LINK] book. Are you using a home-made framework or is it some 3rd part product? Anyway. You should start by making a non-AJAX method for adding comments. In your current setup it would most likely happen by adding post_comment() method in Posts_Model . And then creating a

Cites Useless Code · 2013-04 · Stack Overflow · on “Flash not working on Windows 8 / Internet explorer 10”

Do you actually own foobar.com? If not, you should use example.com, that domain is reserved specifically for examples [LINK] . Also you don't need the `type="text/javascript" attribute [this video]

Cites Useless Code · 2013-04 · Stack Overflow · on “Changing CSS for link of current page with jQuery”

FYI, there is no need to use `type=` in your script tags [this video] , in fact `text/javascript` is not the MIME type for JS.

Cites Wayne Smith · 2014-08 · Stack Overflow · on “issues when using pseudo-classes”

redraw is one of the vast sources of pain and misery that frontend engineers find themselves confronted with. The browser stops what it is doing, and repaints the screen, and makes everything on the screen jump a little bit. Douglas Crockford in "An Inconvenient API - The Theory of the DOM" gives a talk about the real world issues ... [this video]

Cites Useless Code · 2014-10 · Stack Overflow · on “How to call javascript from Jquery function?”

getUserMail is not defined in a scope [LINK] that is accessible to calljs . This is why you get the ReferenceError ; in the context in which you tried to invoke getUserMail there was no function with that name available. // At this point nothing is defined function calljs(){ getUserMail(usermMail); } // now calljs is defined as a global and can be invoked from anywhere $(function() { // this line is calling a function named $ (an alias for jQuery) // and passing it an anonymous function as a parameter. function getUserMail(usermMail) { // This function is being defined inside // the scope of the anonymous function, // it can be used anywhere inside the // anonymous function but not outside i

Cites user3871 · 2015-03 · Stack Overflow · on “HTML file script and CSS placement”

I was watching Doug Crockford's Theory of DOM [this video] video and at 16:50, he talks about placement of <script> tags and CSS <link> . He mentions placing <script src> as close to bottom of body as possible, and <link> as high in the head as possible. From this, I have a few questions: 1) I learned JavaScript by tutorials. Many programs put their JavaScript within their <head> tags just after the CSS <style> tags. Is the information in his (2006?) video outdated now? 2) Do these rules apply to JavaScript <script type="text/javascript"> and CSS <style> tags as well. If so, why, and what are the differences between these tags and the <script src> and <link> tags? 3) He says "reduce the number of

Cites Useless Code · 2015-04 · Stack Overflow · on “Truncate <a> tag text”

I was tempted to downvote solely because you suggested using `document.write`. There are many reasons [LINK] it shouldn't be used. Douglas Crockford on `document.write` [this video] . It is never a good idea to teach beginners bad habits, they might take them up without realizing they are bad habits.

Cites Useless Code · 2015-04 · Stack Overflow · on “Slideshow using PHP and JavaScript”

Avoid using `document.write` [this video] , use `console.log` for debugging instead. Any tutorials that tell you to use `document.write` are over a decade out of date and shouldn't be trusted. You also have a lot of variables that are capitalized. It is valid code, but in JS it has become a convention [LINK] that only constructor functions be capitalized, other variables should start with lowercase letters.

Cites Useless Code · 2015-05 · Stack Overflow · on “A function that ask for a number and squares all the numbers to that number and sums them”

There are a few problems with the code. function sumOfSquares(num) { var i; for (i=0,i<=num,i++){ // You need to use ; to separate the // initialization, condition and // final-expression in the for statement, not a // comma. When using comma to separate them, all 3 // expressions run as the initializer; this // loop doesn't have a condition or a // final-expression, so it will loop forever (or // until the browser throws up a long-running // script warning). // // Also, since you want to count up from 1, you // should start i at 1 instead of 0. In this case // starting at zero is harmless since 0 + 0 * 0 is // still zero, but it adds a needless round and in // other situations this kind of