Archive for the 'Javascript' Category

December 10th 2007

Javascript Framework Speed Tests

A coworker just pointed out a cool JS speed test to me today. The folks over at MooTools have a handy dandy speed test to compare the top three JS framework libraries to each other. As you can see, Prototype seems to be optimized for Firefox, JQuery for IE and MooTools appears to be a nice middle ground for comparable performance cross browser.

http://mootools.net/slickspeed/

No Comments yet »

May 30th 2007

The One Line Cross-Browser Ajax Request Object

The simple task of getting a working XMLHTTPRequest object can quickly turn into a mess of if/then browser checking. With the help of one of my favorite operators, the ternary operator, this becomes a simple one-liner:

  reqObj = window.XMLHttpRequest
      ? new XMLHttpRequest() :
        new ActiveXObject("Microsoft.XMLHTTP");

There you go, it’s that easy? Now, of course, this is an extremely stripped down browser check, with no error checking, so depending on your need, this may not be the best way to go.

No Comments yet »

November 14th 2006

Fun With Flickr Feeds

Flickr has some really great web services, one of the easiest to use is the feeds service. To grab a set of data from flickr in XML format, just open the following URL in your application:
http://api.flickr.com/services/feeds/photos_public.gne?tags=[comma separated tags here]

by default, the feeds are returned in “plain” XML format, to make things more interesting you can specify a format parameter

prefer PHP data? just:

<?php
  include_once("http://api.flickr.com/services/feeds/\
                    photos_public.gne?tags={$tags}&format=php");
  // broken up to fit format, but in practice leave this as one line
  // i now have a $feed array set with all the feed data:
  print_r($feed);
?>

or perhaps json:
to use the json (in javascript) you must first define a function called jsonFlickrFeed which takes in one object. This object will be your flickr feed data, then below that in your HTML head, you include the feed url as a javascript src file:

  <head>
    <title>Flickr Testbed</title>
    <script type="text/javascript">
      var photos = null;
      function jsonFlickrFeed(feedData){
        photos = feedData;
      }
    </script>
    <script type="text/javascript" src="http://api.flickr.com/services/feeds/\
            photos_public.gne?tags=toothbrush,red&format=json">
    </script>
  </head>
...

to view all the other feed formats, check out the formats section of the Flickr Feeds page.

No Comments yet »

November 1st 2006

More Crockford Online: Theory of the DOM

If you liked the “Advanced Javascript” presentation that i posted about last week, then you should enjoy another one of Douglas Crockford’s talks that has been made available online - Douglas Crockfords “Theory of the DOM”

An Inconvenient API: The Theory of the DOM - Part I

An Inconvenient API: The Theory of the DOM - Part II

An Inconvenient API: The Theory of the DOM - Part III

No Comments yet »

October 31st 2006

Prototype Javascript Framework

If you do a lot of Javascript development, and haven’t heard of Prototype, this post will (hopefully) change your life forever. Prototype is a Javascript framework written by Sam Stephenson to create a common foundation for Javascript development.

Download the library from here:
http://prototype.conio.net/

Read the documentation here:
http://www.sergiopereira.com/articles/prototype.js.html

and learn how to use it from the very nicely done quick start guide here:
http://particletree.com/features/quick-guide-to-prototype/

No Comments yet »

October 23rd 2006

Douglas Crockford’s “Advanced Javascript” Talk - Now Public!

Think you know Javascript? Chances are you don’t realize how powerful this language really is. Every few months at Yahoo! Douglas Crockford, our JavaScript Architect, gives an awesome talk that is now available to the public via Yahoo! Video


Advanced Javascript Part I


Advanced Javascript Part II


Advanced Javascript Part III

No Comments yet »