HTML5 in All Browsers
Jan 25th
Back in 2009, Remy Sharp blogged about HTML5 shiv, and his JavaScript project to “enable” HTML5 elements in Internet Explorer.
Bill Peña (@billpena) has released a great blog post and screencast on NetTuts+.
Make sure you check it out.
Progressive Enhancement + CSS3
Jan 17th
The folk at Perishable Press have put together a great guide to Progressive Enhancement and CSS3.
Check it out: http://perishablepress.com/press/2010/01/11/css3-progressive-enhancement-smart-design/
JavaScript: The Singleton Design Pattern
Jan 17th
I’m in the process of developing a “Learning Modern JavaScript” section.
The first in the series is the Singleton Pattern.
You can real the full article at:
http://chrisiona.com/learning-modern-javascript/the-singleton-pattern/
jQuery 1.4 released, benchmarked
Jan 16th
Introduction
jQuery 1.4 has now been released through the great work of John Resig and the jQuery Team. This build saw some great new features, and 207 bug fixes. The team spent a log of time refactoring the internals of jQuery itself, resulting in some significant performance gains (always a good thing).
Performance Tests
Interacting with the DOM can be the slowest part of your Web Application, so I’m targeting selectors and lots of DOM manipulations here. Each of these Performance Tests were run under the following conditions:-
- The jQuery builds used in these tests were 1.2.6 (“1.2″), 1.3.0 (“1.3″) and 1.4.0 (“1.4″)
- Tests were run on a 2.4GHz MacBook Pro with 4GB RAM on 10.5.6 using Safari 4.0.4
- Each test was run 5 times, and averaged for the charts
First Test
Firstly, let’s compare a simple recursive call to append() a div to the document body.
$(document).ready( function(){
for( var i = 0; i<1000; i++ ) {
$("body").append("<div>" + i + "</div>");
}
});
As you can see, there are some slight improvements between each of the major releases. Probably not enough to make a notable difference on their own.

Second Test
Secondly, let’s compare a recursive nested call to append() method. This iteration will find the last div in the DOM, and append another div to it 1000 times over! (uses the :last attribute).
$(document).ready( function(){
for( var i = 0; i<1000; i++ ) {
$("div:last").append("<div>" + i + "</div>");
}
});
Interestingly enough, 1.3 takes longer to complete than the 1.2 build. The notable result is that 1.4 blows the previous builds out of the water.

Third Test
In this test, we have a HTML page with 3,000 nested div’s. The purpose of this test is to set the font colour of all divs to red, but then set the first to blue and the last to green.
$(document).ready( function(){
$("div").css({color: "red"});
$("div:first").css({color: "blue"});
$("div:last").css({color: "green"});
});
As you can see, significant speed gains in 1.4 over the older versions.

Final Test
The final test iterates 3000 times, over code which creates a div, applies some properties, and prepends it to the document body.
for( var i = 0; i<3000; i++ ) {
$('<div/>').attr("id", "testdiv")
.css({
fontSize: "14px",
border: "1px solid red",
backgroundColor: "orange"
})
.html("This is test content")
.click( function(){
alert('Test Div has been clicked!');
})
.prependTo("body");
}
1.4 is certainly the fastest of the three, clearly showing off.

However, there is a new capability in 1.4. It now allows you to pass attributes to the jQuery() object
for( var i = 0; i<3000; i++ ) {
$('<div/>', {
id: "testdiv",
css: {
fontSize: "14px",
border: "1px solid red",
backgroundColor: "orange"
},
html: "This is test content",
click: function(){ alert('Test Div has been clicked!'); }
}).prependTo("body");
}
The result of the new capability is represented as the orange bar. It’s marginally more expensive to complete, but certainly improves code maintainability.

Using Google’s (quick) Edge Cache Servers
<!-- Include jQuery 1.4 --> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
1.4 Gotchyas
- When calling jQuery() with no arguments, it no longer converts it to jQuery(document).
- The add() method now merges and sorts the results
- Incoming JSON data must be correct. jQuery now throws an exception if it receives malformed JSON data.
- For the full list of changes in 1.4, visit the jQuery API site
Related Links
I’m a user experience junkie
Jan 10th
I was reading an article on news.com.au and it got me thinking. Why do I enjoy Apple products as much as I do?
Well I think it comes down to delivering an exceptional user experience, and you can’t do that unless you control as many aspects of the product as possible. In Apple’s case, that means iTunes, their App Store, the operating system and building their own hardware.
Yes, it can be annoying and get expensive, but for those with an appreciation for exceptional user experiences it is worth it. It seems that Google have come to the same conclusion and delivered the Nexus One, a product that IMHO is the closest thing to an iPhone competitor.
Calling me a “sheep” because I have an iPhone and would consider an Apple Tablet annoys me, a lot – I want an exceptional product & experience, and I trust Apple can deliver it. That doesn’t make me a fan boy – it makes me a “User experience junkie”.
Now, I quite like Windows 7 and thank the stars that Microsoft has been able to deliver a great OS once again. But the issue as I see it is that Microsoft have to many hardware partners, and cannot tightly couple their software to any of them. That means Win7 (albeit good) is more ‘generic’ than the fruit company’s operating system. It also means that one bad product from a hardware partner can be detrimental to the future experience and overall opinion of its software.
I work in software, and use a mac everyday – it’s my OS of choice. But even with a pretty & stable Windows 7, I think I will still stay with my mac. It’s earnt my trust.
The xbox 360 is Microsoft’s flag ship, and when Natal comes out it will set the tone for the gaming industry. It is an exceptional product, with an exceptional user experience.
Working to my point just nicely, Microsoft control every core aspect of this exceptional xbox product.
Q.E.D
FixedPosition > Get Position:Fixed working in IE
Jan 9th
I’ve created my first Google Code project. It’s called FixedPosition, which is a jQuery plugin.
Why? Well position: fixed is a powerful CSS attribute, and there are too many ‘conditions’ to getting it working in Internet Explorer.
Check out the example code and project information at http://chrisiona.com/fixedposition/