Archive for February 2009
Detecting browsers javascript hacks in a tweet
Hi folks.
I am recently very fond of the term “code in a tweet” which means that a very useful piece of source code can even fit a Twitter post. Below here is the shortest javascript that can detect IE browser by Andrea (yeah, IE sucks and we have to detect it to eliminate its problems)
IE='\v'=='v'
Moreover, Gareth Heyes has come up with other browser detections and gather them together
//Firefox detector 2/3 by DoctorDan FF=/a/[-1]=='a'
//Firefox 3
FF3=(function x(){})[-5]=='x'
//Firefox 2
FF2=(function x(){})[-6]=='x'
//IE detector I posted previously IE='\v'=='v'
//Safari detector Saf=/a/.__proto__=='//'
//Chrome Chr=/source/.test((/a/.toString+''))
//Opera Op=/^function \(/.test([].sort)
Usage: The variable assignment is the abbreviation of the browser e.g. FF, IE, Op, Saf, Chr which return true or false.
And this is the most interesting part: one-liner to rule them all
B=(function x(){})[-5]=='x'?'FF3':(function x(){})[-6]=='x'?'FF2':/a/[-1]=='a'?'FF':'\v'=='v'?'IE':/a/.__proto__=='//'?'Saf':/s/.test(/a/.toString)?'Chr':/^function \(/.test([].sort)?'Op':'Unknown'
Usage: B will return a string of the abbreviation of the browser
Tell me what do you think? And if you find any cool stuff like that let me know.
MooTools the Ajax experience
[Updated] Sorry to be arrogant and simple minded but I always think jQuery rocks and try to inspire as many people as possible to use or move to jQuery because of one simple reason: the more users and developers use jQuery the better it is and the more plugins will be created.
[Updated] jQuery 1.3 is out and it is super fast ! Read more

I have once used Mootools for one of my projects and it turned out to be running well. The performance was fast and I had no problem implementing its animation effects and plugins. However, I found several complaints about mootools on the Internet that will affect my choice of JS library in the future.
- Mootools does not have any well organized or responsive forum.
- It does not even have all of the many useful threads that were written for 1.1 available. What it does have – a Google group – is so undermonitered that John Resig’s profile shows up on the home page (now what does that say about JQuery responsiveness)! I have never, never! gotten a response to any of the requests I have made on the Google group page, despite my not being a noob.
- No plugins are available unless you already know where to find them, or you write them yourselves. As oppossed to J which makes it easy to get plugins. Yes I know they posted something on the blog.
- SVN was dumped for GIT. Maybe not bad from a technical standpoint, but I don’t know how to use GIT, and am not about to start learning.
- I rarely see the core developers on IRC, probably because we have different hours. But it is very difficult to get answers there, and thread is downright insulting to noobs – no matter how much he wants to learn. Worse though, the channel is not be stored. All of the questions and answers that are served are only to individuals – they cannot be accessed by someone who is searching for an answer. And lets face it – IRC is not good for most users. Is it so hard to have a chat box on the screen that allows for normal people to communicate, or at least to be able to see the thread?! I know a good framework that can be used to write such a tool!