Wed

Jul 20
2005

Marc Hedlund

Marc Hedlund

Unobtrusive DOM Scripting

This manifesto from the Web Standards Project is right on the money in its technical recommendations -- that JavaScript should be linked to HTML only through a <script> tag, and not through embedded code. Still, reading through the manifesto, I couldn't help thinking it was mixing a technical argument for separation of responsibility with a cultural argument against JavaScript prejudices and a design argument against obtrusive JavaScript effects. It seems to me these are three separate things, and, as the authors argue for JavaScript code, they should be in separate documents.


tags:   | comments: 6   | Sphere It
submit:

 
Previous  |  Next

0 TrackBacks

TrackBack URL for this entry: http://blogs.oreilly.com/cgi-bin/mt/mt-t.cgi/4200

Comments: 6

  Josh Peters [07.20.05 12:25 PM]

Heck yeah!

Working in education has especially taught me just how important seperating javascript from a document is. I've found that not depending on client-side scripting for anything makes for accessible documents, while adding dom scripting after the fact can really enhance the document/application without discriminating. My rule is not to let the client do anything the server cannot do.

As people move closer to actually using xhtml for xml applications, this only gets more important, as one should not need to depend on the user agent (browser, bot, or whatever) to be able to parse javascript in order to use a resource.

  John Dowdell [07.20.05 01:02 PM]

I was also confused when reading that document, thanks for validating my reality, Marc.... ;-)

(I try to make summary sentences, and then summary paragraphs, when presented with more than a screenful of text. Sometimes I'm not able to do that with any assurance that I'm accurately distilling the author's words into a more accessible format. This was one of those cases for me too, although you got that "keep JS separate!" admonition I missed. Has the unnamed author(s) confirmed your understanding of that being the key point they wanted to present?)

jd

  Marc Hedlund [07.20.05 01:15 PM]

John, no, I was just looking at the text; I haven't contacted the author. I wanted to like the whole piece, so I read it through a couple of times. I think all of their points are reasonable, but the source-level meaning of "unobtrusive" was the one I wanted to highlight.

  Dori [07.20.05 03:23 PM]

Marc - consider us contacted. ;-)

The main author of the manifesto was PPK, although all of us Task Force members got a chance to put our two cents in.

Looking at the big picture, I can't say that I disagree with your point, and in the long term, we may well break it down into multiple docs. But for the announcement, we needed one single statement that we could point people towards.

Keep an eye on the DOM Scripting Task Force blog -- we've got lots of ideas for the future.


Dori

DOM Scripting Task Force co-leader

  Marc Hedlund [07.20.05 03:34 PM]

Dori, thanks for the note. I'll be interested to see how it goes. I think you're arguing for good purposes.

  Scott Barnes [07.20.05 07:39 PM]

Its called the "Decorater Pattern" and when used can be effective (Macromedia also calls in the Mix-In).

Its how the world of JS should be... for it is wise.

Post A Comment:

 (please be patient, comments may take awhile to post)






Type the characters you see in the picture above.