The Contender
I got around to installing the IE9 RC this weekend. Kudos to Microsoft. At SenchCon, Ed Spencer commented that IE9 was “just like a modern browser”. Since JavaScript performance has been one if IE’s greatest weaknesses, I ran it against a couple benchmarks to see how it compared to the reigning champion, Google Chrome.
First, I triedSunSpider. To my total amazement, IE9 actually bested Chrome on the SunSpider benchmark.
Next, I tried Google’s V8 Benchmark Suite. On this suite, I saw the results I have typically seen before. Chrome posted these results:
And IE9 RC came in with these:

So on V8, Chrome destroys IE9, but on SunSpider, IE9 eeks out a slight lead. I could go in to endless speculation about benchmark optimization and validity, but real world results are what matter. So I’ll give IE9 a fair try as my primary browser for a week and see what happens.
Tuning Your ExtJS Theme
ExtJS is my favorite JavaScript favorite. The guys at Sencha have done an excellent job at building the best JavaScript framework for building intranet RIAs. The only flaw of ExtJS is the lack of themes. Although the provided blue and gray themes are very nice, after looking at them for two years you start to long for more variety.
There have been some attempts to theme ExtJS. Extthemes has built a pretty nice collection of commercial themes, but sometimes all I need is a little bling without the need to completely re-theme the framework. For example, on a recent project, I’m starting to introduce ExtJS and am making use of the Ext.Panel widget for laying out div elements.
Here’s what a basic Panel looks like in ExtJS:

And here’s the code I used to create the panel:
var panel = new Ext.Panel({ width: 200, height: 200, title: 'Test Panel', renderTo: 'box' });
I’ve got a div specified in the HTML like this <div id="box"></div> which is where the Panel is being rendered to. This is very nice if your site’s look-and-feel is baby blue, but this won’t cut it if you need a different color scheme. Fortunately, Panels are extremely easy to stylize through some simple CSS overrides.
The first step is to decide what color you need for the Panel’s header. The default theme uses a gradient image, which looks better than just specifying a background color. Gradients are pretty easy to created in Photoshop, but you can get a very nice gradient that exactly matches your needs by taking advantage of the Themeroller tool for JQuery UI. Use the Header/Toolbar customization and choose the color and gradient effect you want for the header.
After you have the header just the way you want it, download the whole theme bundle, extract it someplace and copy the image file for the header into your project directory.
There are three CSS selectors you need to override to apply your customization to the Panel. They are .x-panel-header, .xpanel-header-text and .x-panel-body. For my example, I just borrowed the header image for the Eggplant theme and configured these selectors to produce the following:

Here is what I specified in my CSS file to override the default style:
.x-panel-header { background: url(resources/images/eggplant.png) center left repeat-x; text-align: center; border-color: #000; } .x-panel-body { border-color: #000; background-color: #fafad2; } .x-panel-header-text { font: bold 14px Consolas, Arial, san-serif; color: #eee; }
In the .x-panel-header selector, I specified the background to be the header image I got out of the Themeroller theme. For a little added bling, I changed the text alignment to center the text and set the border color to black. Note, I renamed the gradient image from the cryptic name Themeroller created to eggplant.png.
For the .x-panel-body selector, I set the border color to match the one I specified in the selector above. If you don’t do this, you’ll still have the default border around the center. I also specify a light-yellow background color for the contents of the Panel.
Finally, for the .x-panel-header-text section, I change the appearance of the font from the default blue text to a white text in a different font.
Now you have a panel which can perfectly match any color scheme you need to support and it gives you a simple way to introduce ExtJS without it standing out from what you are already doing. For example, on my project, I’m going to use a pair of Ext.Panel widgets on the sidebar for navigation and a most-recently-used files list, which looks something like this:

In this example, the theme is still blue, but I changed the header gradient, the shade of blue for the lines, and applied a light-gray background.
Some Tips
- Firebug or Webkit (Chrome/Safari) are your friends. Use the element inspectors to look at what classes are applied to the various ExtJS widgets. Theming ExtJS is all about overriding the existing styles.
- Panels are about the easiest thing to style, and it gets harder from there. If you really want to get a custom theme, I suggest start by working with the
x-theme-gray.cssand then overriding from there. The gray theme will give you widgets that blend pretty easily with any theme, and then you can selectively add some bling to the elements you care about. - Remember that your overridden styles must come after the stylesheet link for ExtJS. For example, if your stylesheet with the overridden styles is called
custom.css, ensure your header section contains this:<link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css"/> <link rel="stylesheet" type="text/css" href="extjs/resources/css/xtheme-gray.css"/> <link rel="stylesheet" type="text/css" href="stylesheets/custom.css"/>
Revenge of the Browser
Last weekend I attended the awesome Texas Javascript conference down in Austin, TX. This was probably the best geek conference I’ve been too. It made the early Rails conference look downright corporate. TXJS had awesome parties sponsored by Google and Facebook, the top names in JavaScript for speakers, and an open bar with mimosas for breakfast. This sets the bar pretty high on the geek awesomeness scale.
One of the most interesting discussions at the conference revolved around server-side JavaScript. Some very clever programmers have taken the V8 JavaScript runtime from Chrome, wrapped it with a library and pushed it out as a runtime for executing JS scripts on the server. The project is called NodeJS and it already has a pretty rich plugin environment around it. The implication is you can actually write a high-performance server-side application in JavaScript.
The trend for the past several years has been for the server-side programming languages to hide the JavaScript from developers. Both Rails and GWT approach things with a “use our language to do it all”. There is obviously value in this approach for people who don’t know JavaScript, but NodeJS suddenly flips that model on its ear.
The NodeJS story is “you use JavaScript already in the browser, so why not use the same skills on the server”. We now have a programming paradigm established at the browser that is pushing in to the lower tiers, rather than the lower tiers pushing out to the web. NodeJS has potential to obsolete a lot of what we think of as server-side development. Both Yahoo and ExtJS have projects in the works that use NodeJS as the backend, and I bet Google must have something going too.
NodeJS is basically the new Ruby. Keep an eye on what the cool kids start doing with it, and give it a try yourself. We’ll be seeing a lot more of it in the future.
JavaScript at the Speed of Sound
The big news for the JavaScript world today came out of the Firefox development team. They working on a new JIT compiler for SpiderMonkey called TraceMonkey. This is going to have huge implications for building RIAs with JavaScript and will expedite the death of both Flash and Silverlight. Why use a plug-in when you can get this kind of performance in just the browser.
This is all slated for Firefox 3.1, so it is still early, but this, along with development in the Safari Webkit space, are going to make the JavaScript world a very interesting place to be.
More gory details can be found on Andreas Gal’s blog post about it.



