with Imagination: by Dustin Diaz

./with Imagination

A JavaScript, CSS, XHTML web log focusing on usability and accessibility by Dustin Diaz

Screencast 01: YUI Basics and DOM Hijacking

Sunday, August 27th, 2006

I’ve finally decided to launch an idea I’ve had in the back of my mind for quite some time so today I present to you the first episode of the WSwI Screencasts. In this episode I demonstrate some of the fundementals of the Yahoo! User Interface utilities and how we can add progressive enhancements to our webpages with only applying the basics.

As a confirmation to the loyal Podcast listeners, this is not a replacement. The podcasts will still continue to hit the web sound waves and hopefully the screencasts will behave as a solid compliment. Enjoy!

Download the Quicktime Version (19 MB)

If you cannot see the video below: get the DivX Web Player (available for both Win & Mac)

51 Responses to “Screencast 01: YUI Basics and DOM Hijacking”

  1. shfx

    Woho! I’m #1 :D now I need to download quicktime :)

  2. Tommy Maintz

    Great addition to your already very interesting website.
    Hope to see you can keep these pod- and screencasts coming.

  3. Tobie Langel

    Excellent screencast. I really liked the concepts explained here. Posted about it on my blog.

  4. Adam Spooner

    Great screencast, Dustin! It’s on my list of to-do’s to check out the YUI and after watching this I’m finally ready to. Quick question for us TextMate users…are you going to release your YUI snippets to the public?

    Thanks

  5. Jesper Haug Karsrud

    Great screencast! Especially liked the part about dollarsigns, and the way they work in YUI compared to Prototype.

    A great first, looking forward to the next one.

  6. David Caunt

    Wow what a great screencast! You managed to cover usability, javascript syntax, and the fantastic YUI library at the same time.

    As an intermediate javascript programmer I found there was plenty of new stuff in there for me.

    Looking forward to the next podcast :)

  7. Kevin Reagan

    Great intro! Thanks! Looking forward to future “episodes”.

  8. Jeff L

    Very nice Dustin, I look forward to more screencasts and trying out some of the stuff you showed in the this one.

  9. Eric Miraglia

    Cool stuff, Dustin. Thanks for sharing this!

  10. JD

    Stop smacking your lips and clearing your throat. Good stuff.

  11. Dustin Diaz

    @Tommy: I do hope to keep them coming. I have to start with the basics first, so this will leave much room for other advanced topics.

    @Tobie: Thanks for the link reference. I’m glad you understood the concepts, that shows that I’ve explained it well enough.

    @Adam: There are a few other snippets that I want to add to Textmate before I release anything. Otherwise, releasing a Textmate plugin for YUI really hadn’t crossed my mind until you mentioned it.

    @Jesper: Indeed, I wanted to make it clear that these were not replacements for Prototype, but a lot of people seem to be familiar with Prototype, so I threw it out there. As a previous frequent user of the Prototye framework, I can appreciate what it might mean to others.

    @David: Your comments are encouraging. Thanks for the feedback.

    @Kevin: I’m glad you’re looking forward to them. This will hopefully keep the ball rolling if enough people are interested.

    @Jeff: Thanks :) As said, more to come.

    @Eric: Good to see you in this neck of the woods. Hopefully this will help people understand some of the underlying concepts in YUI and encourage them to use it.

    @JD: *clears throat* I’ll keep that in mind *smacks lips*

  12. Igor

    Hi Dustin!
    Please don’t get me wrong but I think this screencast was very messy and difficult to follow. The subject was worth attention but it could be squeezed into a smaller clip.
    I think that screencasts like this are a great learning resource and I hope that you make a lot more of them and a bit more focused.
    As they say: Practice makes perfect.
    Thank you for your effort!

  13. Dr J

    Dustin,

    Glad to see you are doing screencasts. I’ve been reading your site for quite a while, but never listened to the podcast. After watching this screencast, I think I’m going to add your podcast to may already huge list of podcasts.

  14. Carson

    Love it Dustin, thank you - keep this stuff up.

  15. Dustin Diaz

    @Igor: At which point was it messy? And if you’re saying it could be squeezed into a smaller clip, at what point was it difficult to follow? Should it have been longer? I appreciate your honest feedback, but I hope that you can provide some concrete details as that will most likely improve them in the future :) Indeed, practice makes perfect, but perfection can be defined to its own scope. Eg: I believe this was “as perfect as it’s gonna get” for a “first episode.” I was quite happy with the way it turned out - especially considering the time I spent on it.

    @Carson: Will do.

  16. Ross

    Excellent YUI demo. Look forward to the next screencast.

  17. Cheng Siang, Heng

    I really appreatiate the work you have done. It makes me undestand something in javascript. Thank for the good work.

  18. Sbastien Guillon

    This is absolutely great, I’ll join the others in saying I’d like to see more of these coming.

  19. Ross Bruniges

    practical demonstrations are the best best best way to teach - this is going to be essential viewing for me - bloody brilliant stuff!!

  20. fred Moerman

    this was actually usefull!
    not that I expected anything else, but on ‘the Internet of DOOM’ it is far, far between the realy interesting bits.
    tnkx

  21. Ciro

    Good introduction about YUI. I would like to see a more expert screencast :-)

  22. Nate

    Thanks for the great demo. As someone who is dabbling with the different JS libraries, it was very nice to see what you can accomplish and HOW you can accomplish it. I thought it was easy to follow, the examples were great, and you brought everything full circle.

    Looking forward to more of these in the future!

  23. Thomas Messier

    Great screencast, it’s impressive that you actually took the time to do all this, thanks. I do have a question though. Is there any particular reason why you code things like this:

    foo = function() {
    return {
    init: function() {
    // Code here
    }
    };
    }();

    As opposed to this:

    foo = {
    init: function() {
    // Code here
    }
    }

    Calling foo.init() for both of the above seems to produce the same result, and the second syntax is shorter, so I was under the impression that it’s not just a matter of preference.

  24. Thomas Messier

    On second thought, I think I get it. It’s useful if you want to define some variables to be used only within that function scope, which you can’t do if you just define an object. Subtle, but clever. Any other reasons?

  25. Dustin Diaz

    @Thomas: I like the modular format of returning an object just so that I can get my private properties and methods. That really is pretty much the main reason. It prevents any collisions and avoids the global scope. Keep in mind you can do this with the prototype as well to do some clever stuff. Eg:

    var Foo = {  };
    Foo.prototype = function() {
      var private_var = 1;
      return {
        go : function() {  },
        do_something : function() {  }
      };
    }();
    var bla = new Foo;
    bla.go();
    
  26. AndyC

    Great introduction to YUI - thanks Dustin. Ignore the comments about it being messy. It went at just the right pace for me. Looking forward to the next instalment!

  27. vig0

    Nice introduction to YUI. Thanks.

  28. Will

    Thanks Dustin. I’ve been interesting in learning more about YUI for a while now and this was a great introduction.

  29. JG

    Great screencast! Very easy to follow and provided a bag full of tips and tricks. Having coded JavaScript since ‘98, I’m still NEW to the “object literal” format. My old school approach to JavaScript objects were to declare everything inside a function. All my vars were private, as well as functions (unless I mapped them to be public). I’ve been looking for a way to obtain the private/public feature again through “object literal” notation. You cleared this up for me in the screencast. Again, thanks!

  30. Marien

    Hi Dustin,

    Just wanted to let you know that you’ve made my javascript skills better for quite some time now.
    Esspecially the yahoo library stuff has made my work easier and more fun to do. Since this screencast were the basics, i still learned from it, i’m really looking forward on the more advanced stuff! So keep on screencasting!

  31. Dan Webb

    Alright Dustin,

    Yeah, good stuff. You’re coding style is nice and clean. By the way, what screencasting s/w did you use?

  32. Travis Young

    Great idea and very edutaining! Thanks for sharing with the world! Looking forward to the next one.

  33. howie

    How will be the Howard Stern of web podcasts?

  34. Brendon

    Hey Dustin, well done. My only suggestion would be to set your mouse cursor off the screen while primarily using the keyboard for interaction. It’s a little distracting and although it’s quite small, it can still cover up an important character or two (in future screencasts).

  35. Matt

    Great stuff! It’s like MTV for web developers. Thanks! Hope you have more in the future.

  36. rtpHarry

    Hey Dustin, seems in the past few weeks you have been everywhere! I stumbled upon your podcast in iTunes (only one is archived still :( but i found the rest on Odeo and manually put them on my iPod), then I start watching a video and it turns out its your screen cast. Inspired I set about looking for more examples, and what do I find? Top 10 things you can do with YUI which i used one of the examples to make a slide out “email a friend” feature. When I finally wrestled it into submission (the first time i’d seen javascript in about 5 years was on your screencast) I thought the perfect thing to finish it off would be an ajax form. Guess where I ended up…

    Anyway, point 1) how about encoding the screencast in ipod format? Have you tried it? is it unreadable?

    And a side point, that light grey text you use on this comment form… well I have google toolbar with autocomplete and all I can see is a vaguely grey fuzz, just thought u’d like to know!

  37. Jacqui

    Thank you, Dustin. This is great. I’ve sent this to several developers who wanted a quick overview of YUI.

  38. genius551v

    more, more, MORE, M O R E ! ! ! plz…. :-) this is great!

  39. tranzparency

    That didn’t work out so well.. Oops, too much free as in beer. Let me try again. Awesome screencast by the way!

    
    			YAHOO.example = function() {
    				var $E = YAHOO.util.Event;
    				var $D = YAHOO.util.Dom;
    				// return value.  Uses the function.
    				return {
    					init : function() {
    						$E.on('my-link', 'click', this.foo);
    					},
    					foo : function() {
    						$E.stopEvent(e);
    						alert("You've been hijacked");
    					},
    					bar: function() {
    
    					}
    				};
    			}();
    
    			YAHOO.util.Event.on(window, 'load', YAHOO.example.init, Yahoo.example, true);
    
  40. John T.

    I am having a heck of a time lately with variable scope.

    Based upon your coding style, I am struggling with this example. Prior to this project I am on , I have stayed away from this “scoping” problem.

    I simply want to be able to manipulate the value of a “public” variable. In this example, how would I modify the dustinDiaz var from within my init function???

    Thanks.

    
    YAHOO.example = function() {
    
    		var $D = YAHOO.util.Dom;
    		var $E = YAHOO.util.Event;
    		var $A = YAHOO.util.Anim;
    		var $M = YAHOO.util.Motion;
    		var $DD = YAHOO.util.DD;
    		var $ = $D.get;
    
    		// Public Variables??
    		var dustinDiaz;
    
    						return {
    
    							init : function() {
    
    								// I WANT TO CHANGE THE VAR
    								// dustinDiaz, but cannot!
    								dustinDiaz = "coder";  // Won't work
    
    							}
    						}
    
    	}();
    
    	// Fire when available
    	YAHOO.util.Event.onAvailable('doc',YAHOO.example.init, YAHOO.example, true);
    
    
  41. Gags

    Perfect.

    There seems to be so many programming resources aimed at beginners or forum discussions by complete experts and this came at exactly the right level.

    Grap the intermediate developers out there and help us get up there….

    Thanks for your time.

  42. Yahoo! User Interface Basics and DOM Hijacking :: Tech Videos, Screencasts, Webinars

    […] Video is here. Tags: AJAX, Companies, Development, Javascript, Screencasts, Technologies, Yahoo! […]

  43. fireyy blog » Intype,基于Windows平台的TextMate?

    […] BlogAboutArchivesResourcesWeb ColorLinks Intype,基于Windows平台的TextMate?Intype,基于Windows平台的TextMate? WEBLOGWEBLOG Tagged as: Intype, TextMate 网上说Mac OS X下的TextMate和Linux下的VIM很酷,具体怎么个酷法…不知道…有耐心的可以看看这个,里面的编辑器就是TextMate. 虽然目前在使用的editplus已经很不错了,但是人(我自己)总是会犯贱的,有了新的东西,总会期待…(简洁的界面和完善的代码片段是我所期待的) Intype最新的发布版本可以到这里找,新的Alpha 0.2.0.236版本已经可以支持更换字体了,换上“新宋体”以后,中文不再是一堆方框,但是说实话…英文字体挺难看的。目前不推荐马上换用,因为连基本的Undo/Redo还没有 ^_^ […]

  44. Using SciTE with TextMate Style Snippets - Monday By Noon

    […] Ever since watching Dustin Diaz’s first screencast, I was incredibly jealous of TextMate (specifically the keyboard triggered snippets). I was on a mission to find an alternative that wasn’t limited to Mac OS X as it was clear there wouldn’t be a Linux version of TextMate. There are quite a few suggestions on the TextMate site itself, but I found nothing that mimicked the Snippets functionality of TextMate properly. E TextEditor came out for Windows, making me even more jealous. Now there was an application for Windows that performed similarly to TextMate, and I had nothing to work with. The author of E indicated that there would eventually be a Linux version, but not until the Windows version was final. After a continued search, I finally came upon SciTE Snippets. […]

  45. Joey

    Easy to follow, fun and not boring! Thanks for this and everything else you do for other people. By the way, I also enjoyed your Youza mf YouTube vid, but I don’t recognize the song, mind telling me? It’s funny as hell and I have to go watch it again now..

  46. Yui Yahoo User Interface Video Screencast - Englisch

    […] Das sehr ausfürliche und in die Tiefe gehende Yui Video Tutorial finden Sie hier. Sie benötigen den DivX Web Player. Diesen können Sie direkt auf der Video Seite runterladen und installieren. […]

  47. Ken L.

    Hey Dustin,
    Thanks for the great tutorial. I have a question. Some yui examples on the developer.yahoo.com/yui website wrap their code like this:


    (function(){code to execute}();

    Is there much of a difference of doing it this way than the way you showed in the screencast? Are there advantages of doing it one way over the other? Thanks a lot.

    (I believe this is the format you showed in the screencast)

    YAHOO.example = function(){
    return {
    init: function(){code to execute}
    }
    }();
    YAHOO.util.Event.on(window,'load',YAHOO.example.init, YAHOO.example,true);

  48. Eric

    First - many thx for the great tutorial! I just finished coding a hijacking of the dom the old fashioned way but this is a great way to intro YUI which I’m just starting to use. The only criticism I have of the screencast, constructive I hope, is that the format makes it hard to scroll forward and backward in the cast - which I like doing as I follow along taking notes or trying out the code.

    thx again!

  49. Eric

    hah! whoops - and now I see the ‘download the quicktime version’ link. Perfect! Never mind except for the thx and great tutorial and all :)!

  50. John

    FYI the Xvid codec works great with your screencast. The only problem I had was I had to hack on my pluginreg.dat to make Firefox recognize that Windows Media Player plays divx and xvid files. The usual caveats for modifying pluginreg.dat apply - close firefox first, make sure to change the plugin count too (above the plugin entry in pluginreg.dat)

  51. Dudewheresmycar

    Where does YAHOO.log go.

    How can i see it.

Leave a Reply

Phone Number:

If you're about to post code in your comment, please wrap your code with the tag-combo <pre><code>. Also please escape your html entities - otherwise they will be stripped out. I recommend using postable.

Get "JavaScript Design Patterns"

"As a web developer, you'll already know that JavaScript™ is a powerful language, allowing you to add an impressive array of dynamic functionality to otherwise static web sites. But there is more power waiting to be unlocked--JavaScript is capable of full object-oriented capabilities, and by applying OOP principles, best practices, and design patterns to your code, you can make it more powerful, more efficient, and easier to work with alone or as part of a team."

Buy JS Design Patterns from Amazon.com Buy JS Design Patterns from Apress

Flickr

Submit a Prototype

All content copyright © 2003 - 2007 under the Creative Commons License. Wanna know something? Just ask.

About | Archives | Blog Search

[x] close

Loading...

Submit a prototype

By checking this prototype I agree that I am not submitting false credentials, pornography, or a hate crime website. I also understand that by submitting my entry I may or may not be accepted, and if accepted, my entry may be taken down at any given time if I violate these terms.