-
Get a monthly update on best practices for delivering successful software.
Another talk that was really more about general Ajax performance, rather than GWT performance. I've done a bit of work here myself (see chapter 9), so I'm always looking for some new tips and tricks. Joel Webber did a manful job going through the usual suspects -- fewer HTTP requests, bundle images, compress your JavaScript, perceived performance and actual performance are two different things.
Maybe the biggest bombshell was his recommendation to use innerHTML to build large DOM structures; it was an order of magnitude faster in all browsers than direct DOM manipulation. While that recommendation seems reasonable, it makes the GWT abstraction even leakier.
Some more GWT specific perf recommendations:
Some quotes:
"Our JavaScript doesn't gzip quite as much as others, because our JavaScript doesn't include as much redundant crap."
"We had a hard time measuring JavaScript compilation because it takes so little time on modern computers."
"Firebug is often wrong when it comes to network timing. It has led me down a rathole several times."
"HTTP requests are the most time consuming thing you will do. DOM manipulation is next."
Technorati Tags: gwt, ajax, performance
Topics: GWT, Performance
A while back I contributed a chapter on Ajax optimization to Real-World AJAX, and as a part of that effort I did quite a bit of digging around for tools to do profiling in IE. The pickings were slim. Now whenever a new book on Ajax comes along, I take it as a point of professional interest to check out its section on profiling and optimization, and so far the lack of progress in tools for IE is depressing. What a contrast, though, between Firefox and IE: while Firefox now has a souped up FireBug and the venerable Venkman, IE's got the same old developer tool-bar, the script debugger and various HTTP proxies to debug XHR and other requests. Of course there's always Visual Studio. Blech. How many virtual machines can you run with IE6 + VS, IE7 + VS? I need a 6GB laptop to get reasonable performance, and even then I don't get profiling.
So, what are the options for profiling code in IE?

There are a few other things on the horizon, such as AjaxView, a server-side proxy that rewrites and instruments your JavaScript as it is served up. Still experimental. I realize that the above is a potentially bigger concept than a plain old profiler, but how about starting with the simpler ideas and working our way up?
Technorati Tags: ajax, tools, profiling, javascript
Topics: Ajax Tools, Javascript, Performance
I was looking for a quick way to profile some code in IE. I didn't want to grab Tito (commercial) or JsLex (browser independent, sweet, but a bit of a hog). So I went hunting for a simple little AOP library for Javascript and came across Ajaxpect. In 58 lines of Javascript, it gives you the ability to add before, after and around advice. From the included example:
// Example business logic var thing = { makeGreeting: function(text) { return 'Hello ' + text + '!'; } }alert(thing.makeGreeting('world')); // Hello world!
// Advice definitions function aopizeAdvice(args) { args[0] = 'AOP ' + args[0]; return args; } function shoutAdvice(result) { return result.toUpperCase(); } function ciaoAdvice() { return 'Bye-bye!'; }
// Adding advices Ajaxpect.addBefore(thing, 'makeGreeting', aopizeAdvice); alert(thing.makeGreeting('world')); // Hello AOP world! Ajaxpect.addAfter(thing, /make*/, shoutAdvice); alert(thing.makeGreeting('world')); // HELLO AOP WORLD! var filter = function(name) { return name.indexOf('Greet') != -1 } Ajaxpect.addAround(thing, filter, ciaoAdvice); alert(thing.makeGreeting('world')); // Bye-bye!
Technorati Tags: ajax, aop, profiling
Topics: IE, Performance
Without a doubt Ajax application are becomming more powerful. That also means that Javascript files are getting bigger and more complex. One solution is to use mod_gzip and mod_deflate (Apache) or HTTP compression (IIS). This means adding extra processing time both at the server and the client, however. One other way to cut down on bandwidth and memory is to compress the Javascript, after all, the browser doesn't need the nicely formated Javascript with white space and comments. You can just trim all of that out and save tons of space.
With that in mind, I decided to test out some of the better known Javascript compression algorithms. My test consisted of compressing three files: ClientEngine.js from the Echo2 framework, prototype.js from Prototype version 1.4.0, and a GWT ( Google Web Toolkit) compiled file from a small widget project. The GWT file was edited slightly to turn it from an HTML file into a Javascript file.
The compression tools tested were:
The results of my test are in the table below.
| File | Size | Memtronics Crunch |
Memtronics Compress |
Dojo Shrinksafe |
Creativyst | Packer | JSMin |
| Prototype | 47k | 28.91% | 69.52% | 30.96% | 18.52% | 59.40% | 23.42% |
| ClientEngine | 104k | 53.93% | 83.63% | 58.62% | 49.15% | 79.40% | 51.28% |
| GWT File | 42k | 8.11% | 52.43% | -1.00% | 0.00% | 23.30% | 5.96% |
The GWT file is already partially compressed, so a more fundamental transformation needs to happen in order to squeeze it some more. The Echo2 file was the largest and also was formatted for human consumption with comments, indentation, descriptive identifiers, etc., so it showed the greatest compression ratio.
Of the three "advanced" compressors, all of them had issues with prototype.js (syntax errors in the resulting code), but Dojo Shrinksafe didn't have any issues with the other two files. Packer seemed to work OK in IE6, but not in Firefox. Memtronic seemed to have problems in all three in both IE6 and Firefox.
The lesson? Test your compressed Javascript in all browser versions you plan to support (JsUnit, anyone?) or just use mod_deflate and company to handle your compression needs.
Topics: Javascript, Performance