A perspective on jQuery 1.2.6’s performance

John Resig and his team have come up with yet another release of one of the worlds best JavaScript-library: jQuery. Among the news in version 1.2.6 are better performance for a lot of different parts of the library and the inclusion of the much used Dimensions-plugin into the jQuery-core.

Congratulations to the jQuery-team on this release!

Out of pure curiosity I compared what jQuery has accomplished in this release to what have been accomplished with DOMAssistant.

The Slickspeed-test that are hosted on the DOMAssistant-webpage has already been updated by Robert with the new jQuery. Running that on some Windows browsers gives the results that DOMAssistant are these many times faster than jQuery:

Safari 3.1: around 20.8x faster
IE 7: around 2.4x faster
FF 3: around 1.3x faster

As far as I know Safari 3.1 uses the same WebKit-version as the iPhone does which means that DOMAssistants CSS-selectors are more than twenty times as fast as jQuerys on an iPhone. Perhaps DOMAssistant is a good choice for some handheld AJAX-madness?

I’m not saying that DOMAssistant is better than jQuery - jQuery is fantastic library. These figures however shows that DOMAssistant can, in some areas, deliver not only as good results as jQuery’s but in some cases even much better results. That means that you in some situations might get a better user experience by choosing a library such as DOMAssistant than you would get by choosing a library such as jQuery.

Update: The results from Safari 3.1 can’t be compared to jQuery’s because of their intentional exclusion of querySelectorAll caused by an unstable implementation in Safari as John Resig commented.

DOMAssistant 2.7.1 and something about the future

We released a mantaince release of DOMAssistant today - version 2.7.1 - containing some smaller bug fixes and enhancement to the already existing feature set. The official blog has a change log.

In the official blog it’s also mentioned a few things about the future of DOMAssistant In the next major release we will hopefully have improved the event model with for example custom events which I’m very excited about and there will hopefully be a few other nice additions if they can qualify for the core.

Most of the new functionality to DOMAssistant will come through plug-ins though. There will be no animations in core for example because animations aren’t really a core part of what DOMAssistant is all about bur rather a nice addition in some applications that would like to have an advanced graphical appearence.

I’m working on a few plug-ins myself. The “DOMValidator” and the “DOMEffects” hasn’t gotten any updates latel. The validator should work fine while there may be some issues with the effects.

A new plug-in has been added to the “DOMEffects” repository and manual (out of laziness). The new plugin enables you to work with selections through DOMAssistant and should be considered to be in alpha. To get info from selections works ppretty well, but the modification of selections isn’t working quite as smooth yet. As with the other plug-ins work are being done when I’ve got time - which I sometimes got plenty of and sometimes, like now, haven’t got a second of.

Should Microsoft do an Apple?

Read an article that states that “Windows is collapsing“. The product that Microsoft once could be proud of has gone really bad lately and the question is - what should Microsoft do?

Microsoft has many talented coders and can deliver really good products. They should instead of focusing on Windows focus on supporting the good things they’ve got and take advantage of the ever growing Internet and there the Windows-core isn’t really needed so instead they should perhaps go Unix like everybody else?

A Unix-Windows with .NET would be similar to OS X, which is Unix with Cocoa, and Linux with KDE or similar. As far as I know .NET is a success for Microsoft and therefor they should do like Apple has done with Cocoa and use the best possible OS to promote it.

By developing a compatibility software like Wine (or even support or fork Wine) Microsoft could make a switch to a Unix platform as painless as Apple’s switch from PowerPC to Intel, so there’s really no technical obstacles for a switch as I can see.

On top of a Unix-switch I also think that Microsoft should either buy Opera or start using Gecko as the next-gen engine in Internet Explorer to further emphasize a new focus on the Internet.

If Microsoft did this and showed the customers that they care more about them than about a dysfunctional operating system they would regain much lost trust. If they replace everything that they gain a bad reputation from and only have the good stuff left - how could anybody hate them?

Perhaps Yahoo could help Microsoft to make a journey such as this since Yahoo is a company already familiar with a modern liberal open source web 2.0 world. Perhaps if Microsoft bought Yahoo it could be what Next was for Apple? A revival.

Latest is not always greatest, K2 and WordPress 2.5

I’m always keen to have the latest of everything and sometimes that can cause problem when the latest of everything isn’t synced to each other and such was the case when I updated this blog to WordPress 2.5 prior to my K2-theme had gained support for it and as such I’ve now lost my dashboard.

But I’ve nothing to fear - there exists workarounds and the K2-team are working on supporting 2.5 but until thats done I’m perhaps being a bit extra quiet (oh no - my reader are so going to miss my weekly entry)

In other news I can tell that I now have a portfolio (in Swedish though) which shows of some of the websites I’ve been working on in the past three years.

New page for all of my free scripts

Over the time I’ve created some scripts that I’ve shared with the world but I’ve lacked a page to gather them all on making it hard for people who have found one of my scripts to find another of my scripts. Add to this the failure of my personal blog’s host in September last year that made one of my scripts unavailable I really had to create a page for my scripts.

Well - now I’ve done so - I’ve listed them all on a subpage to my company’s site and this time I decided to make the page in English so everyone can read it. There you find free scripts for Greasemonkey, Operator and DOMAssistant and in the future hopefully even more.

Freelancing, customers and terms

Being a freelancing webdeveloper I’ve got many projects going on at the same time with many different customers - often with challenges such as tight deadlines tied to them. It’s sometimes hard to get everything correct in time, but so far everything has went well for me and my customers seems happy with my work and I’m happy with my customers.

What would happen though if one day a customer of mine says that I’ve screwed up totally with a project? What happens if that customer sues me and I end up in court? I probably and hopefully will never find out, but I would anyhow feel a lot safer if I could minimize the risks involved in the projects for both me and my customers and I’m sure other freelancers feels the same way.

Today I’m using no special terms in the deals with my customers. I have searched for some free ones that could suit me but haven’t found any good. I could try to write them myself - I’ve actually done so lately with a minimalistic attempt - but such terms will never be anywhere near good enough without the help of a lawyer. Lawyers are expensive  thoughand I’m not really feeling rich enough to be able to afford one on my own.

Therefor I’ve teamed up with Peter Danulf of Makeover Media. Together we’re now conducting a survey as a basis for an application we’re going to send to foundations in hope of finding money to develop free, hopefully Creative Commons licensed, terms for all of the Swedish freelancing web workers and the smaller Swedish web firms. (The terms would be in Swedish made after Swedish law)

Our main focus are terms suitable for B2B contracts - although if we find enough finance to also develop terms for additional kind of contracts we would certainly like to do that as well.

Does this sound interesting to you? If you’re Swedish we would love if you took the time to fill out the survey, it’s very short and very valuable to us. I will continue to write about our progress on this project on this blog.

Testreleases of DOMEffects and DOMValidator

DOMAssistant - the lightweight highly efficient JavaScript-library that doesn’t fix all of world problems but rather just simplifies common DOM-operations - got official plugin-support in it’s 2.6-release.

Since DOMAssistant only simplifies common DOM-operations a common complaint has been the lack of animations capabilities. How would it be possible to replace jQuery or Mootools with DOMAssistant if those libraries would still be needed for the animations?

Following the same pattern as Prototype and Script.aculo.us I’ve therefor created DOMEffects - a plugin for DOMAssistant which adds the ability to animate the CSS-attributes of elements - both usual “unit-based” attributes and color-attributes.

The DOMEffects package consists of three modules - one core module containing the animation-method (and a shortcut for cross-browser opacity) and two helper modules. One of the helper modules makes it easy to show and hide and element by fading it in and out and another one makes it easy to do yellow-fade-technique-like highlightning of elements.

I also created another plugin, DOMValidator, that enables easy validation of forms. It’s not really new but rather a conversion of some old code I created. It adds two methods - one to add the default validation rules of an element and another one to validate an element. DOMValidator easily validates many elements at the same time and makes it very easy to visually show the result of the validation as well as adding error messages to the site.

DOMValidator works very well with DOMAssistant’s first plugin ever, the AJAXFormsPlugin by Robert Nyman. Prior to AJAXFormsPlugin’s submission of a form a custom method may be called to allow the abortion of the submission. By calling the validation method of the forms element in that method one can easily abort the submission when invalid data has been entered.

Both DOMEffects and DOMValidator are under active development. Their releases are not stable - especially not DOMEffects - although I do expect them to work without any major flaws or bugs. I need feedback on the syntax of the methods and how it can be improved as well as feedback on the code itself. Any feedback is highly appreciated :)

Feedback can be handed to me here in the comments, through e-mail to me (you can find the address elsewhere on my pages - no need to feed it to any more spambots) or through the two plugins own issue trackers.

Update:  Robert Nyman today wrote about my plugins as well as about some other exciting DOMAssistant news - like Roger’s new TextMate bundle - makes me want a Mac even more…

How to update Aptana without choking the internet

Downloading an update for Aptana from inside Eclipse can choke your internet, as I’ve written about before. That isn’t great fun - but relax - a solution exists.

You can update Aptana manually by downloading an archive of the update site and adding to Eclipse as an archived update site. Then you ask Eclipse to look for updates from the archived site instead of from the net and you will have an updated Aptana and a working internet at the same time - marvelous!

It’s quite a massive download though, 85 mb heavy.

Firefox and IE ignores Vary-headers in XMLHttpRequest?

One month ago I wrote about how it could be good to use custom headers in your AJAX-calls but that Firefox didn’t handle custom headers very good on redirect. Now I’m not answering with redirects to JSON-requests anymore but that doesn’t stop the browsers from making a mess out of my custom headers…

I have specified that my XMLHttpRequests only accept answers as JSON-data. That’s because it’s the only kind of data-format my AJAX-client understands and since I’m also coding the server why code for many different data formats? This is how I added the custom header:

ajaxObject.setRequestHeader('Accept', 'application/json');

My server answers with some JSON-data and everything is nice and well - or not. Because I use the same URI for both the XHTML-data and the JSON-data the browsers seems to mix the two up - even though all my responses from multiformat URI:s carries a Vary-header with it to alert browsers that different Accept-headers results in different answers. That header looks like this:

Vary: Accept

I’ve built a site with a paging mechanism. It loads the first page by default when I request it as http://foo.bar/ and page number two when requested as http://foo.bar/2. I load new page’s data by requesting it as JSON and when I return to the first page I also request that data as JSON but then Firefox and IE acts a bit weird…

Firefox’s response to loading two different data formats from the same URI is to remember the latter of those when it’s time to use the back button. The user is then presented with an option of downloading the JSON-data which for most people isn’t that useful…

Internet Explorer on the other hand, both version 6 and 7, remembers the XHTML-version of the data and thinks that it is a waste of bandwidth to download the data again and presents my AJAX-client with a data format it can’t read.

Both these browsers behavior are wrong as I’ve understood. URI means “Uniform Resource Identifier” and it is same resource that both the browsers and my AJAX-client request only that my client prefers to have it in a different format and the browsers are alerted about that fact with a Very-header but ignores it.

It should be noted that Safari behaves correctly. If Opera behaves correctly I haven’t had the possibility of testing (since Opera doesn’t like my custom made host-file and therefor can’t reach my development server…)

DOMAssistant 2.6 has been released

The JavaScript-library of my choice and which I’m part of the team behind, DOMAssistant, has been released in a new version.

One of the top news in 2.6 is the speed optimization that Robert, the creator behind it, has done making this one of the fastest (if not the fastest) library around - and that’s why I love DOMAssistant, because it cares about speed and weight.

The other top news is the new plugin system which enables the creation of additional features very very fast and easy. I’m of course trying this out at the moment in the creation of an effect library, DOMEffects, that will let developers have some eye candy without putting too much weight onto their products.

DOMAssistant has of course gotten some other fixes and improvements as well and is now better than ever. Congratulations Robert to a fabulous release and stay tuned for the release of my plugin in the coming weeks.