Posts Tagged ‘webdevtrick’

Creating progressively enhanced DOM applications with ViewsHandler

Tuesday, August 19th, 2008

When I taught a bunch of students last month the ways of the DOM and explained progressive enhancement they were very happy about the ideas but rightfully exclaimed that DOM scripting can get verbose and repetitive. This is when I had to idea to write ViewsHandler , a small framework to write DOM applications.

ViewsHandler is not meant to be a JavaScript templating engine, as I found that whilst you have to create a lot of HTML with DOM, the parts that change in the app are not that many. Templating engines would replace the whole view, ViewsHandler instead offers you to create HTML, add it to a shell or application canvas and store references to the parts that change. That way you only create your HTML once and then only do minor changes to cached DOM elements when you need to.

As a demo I created a small Flickr slide show using ViewsHandler which was exactly the task that I had given my class :)

What do you think?

Conjuring YUI from thin air

Saturday, August 2nd, 2008

I love the YUI loader as it is a great way of including the YUI on the fly. The coolest bits about it is that it gets the YUI components from the CDN and knows the dependencies so I don’t have to. So if I need the YUI for something, I don’t need extra SCRIPT nodes a maintainer has to include, just my SCRIPT. However, what we still need is including the YUI loader itself.

Unless… you use the YAHOO_config listener. This thing is older than both YUI get and YUI Loader and is an object method that gets called every time a YUI component is loaded. So why not load the YUI Loader using this?

One problem is that the YUI Loader doesn’t call the config listener saying it is a loader, but saying it is the get utility. Another issue is that it does not work to execute the Loader immediately after it called itself “get”. The workaround is to use a timeout.

Wrap all of that inside the YAHOO_config object and you’ll conjure the YUI out of thin air. The following example loads YUI Dom, YUI Event and alerts “done” once all is ready. Check it out here


YAHOO_config = function(){
  var s = document.createElement('script');
  s.setAttribute('type','text/javascript');
  s.setAttribute('src','http://yui.yahooapis.com/2.5.2/'+
                 'build/yuiloader/yuiloader-beta-min.js');
  document.getElementsByTagName('head')[0].appendChild(s);
  return{
    listener:function(o){
      if(o.name === ‘get’){
        window.setTimeout(YAHOO_config.ready,1);
      }
    },
    ready:function(){
      var loader = new YAHOO.util.YUILoader();
      var dependencies = ['yahoo','dom','event'];
      loader.require(dependencies);
      loader.loadOptional = true;
      loader.insert({
        onSuccess:function(){
          console.log(’done!’);
        }
      });
    }
  };
}();

Thanks to Alex Liu to get the setTimeout trick.

Agent YUI - don’t miss these YUI tutorials

Sunday, July 27th, 2008

My esteemed colleage Klaus Komenda seems to spend as much time as I do writing cool stuff for the masses, but somehow he doesn’t crop up in a lot of to-read lists. For shame, I say, pulling up my trousers until they reach my armpits (yes, I watched Simpsons) and I point you, esteemed reader to a series of articles explaining the YUI from ground up entitled Agent YUI:

Yes, I am also taken with them as I like Bond a lot.

Creating Happy Little Web Sites audio recording available on the Guardian blog

Monday, July 7th, 2008

Two weeks ago I went to East London to give a “brown bag” presentation at the office of the Guardian. In a very crowded room around 30 developers sat and listened to me raving about best practices in web development and what the YUI already solved for you.

There is a very nice write-up on the inside guardian blog and they also host the podcast mp3 of the talk.

The slides for the talk are on slideshare:

Creating Happy Little Websites

Creating Happy Little Websites

A brown bag presentation I gave at the Guardian in London, England to explain some of the reasons and best practices that should be applied to successful web development.

Read "Creating Happy Little Websites" with Easy SlideShare

It is very cool to see your name on an old-school media site and the way they wrote up what the talk is about makes me realize that journalism will never be replaced by blogging and twitter.

Creating Happy Little Web Sites - my tech talk at the Guardian

Saturday, June 28th, 2008

Here’s a presentation I have given today at the Guardian office in London. In it I am covering the different great ideas I found out about developing web sites. Check the presentation here:

Creating Happy Little Websites

Creating Happy Little Websites

A brown bag presentation I gave at the Guardian in London, England to explain some of the reasons and best practices that should be applied to successful web development.

Read "Creating Happy Little Websites" with Easy SlideShare

The Guardian have recorded my talk and will release it on the Inside Guardian blog

@mediaAjax
Scripting Enabled - hacking the web to be more accessible - London, England 19th and 20th of September 2008
Wait till I come! is the blog of , a developer evangelist living and working in London, England. Download vcard.

Feed me, Seymour: Entries (RSS) and Comments (RSS).