Comparing the performance of Math.floor(), parseInt and a (bitwise) shift

I read somewhere that a bitwise left shift was a faster method of removing a fraction of a floating point number in Javascript than using parseInt or Math.floor().

I wasn’t surprised that parseInt was slow, since I think it parses the number as a string, but the left shift being faster than Math.floor() was a bit more puzzling to me.

So I decided to make a JSPerf test to compare those three methods.

Read on for the full results

Is Node.js the next Ruby on Rails?

I got into a conversation at work today about whether or not Node.js might become as popular and as ubiquitous as Ruby on Rails has become, or if it’s just a fad.

At first I was like “It’s going to become the most used framework evar!” But then I thought about it a bit more and realized that this might not be the case.

Arnor’s Handy Bookmarklet for Measuring Page Scroll Performance

I’ve been dealing with some unfortunate scroll performance issues at work lately, and to aid me in that task I’ve been using a handy CSS stress test bookmarklet made by Andy Edinborough. It works by iterating through all your classes and measuring the performance improvement you get from dropping them – thus helping you find out which classes are making your page scroll speed slow. It’s handy but the use case too constrained for my needs.

I wanted to be able to simply run a test anywhere on the page just for a single run, and I didn’t really care about the classes, since I was manually disabling styles and moving things around, unbinding event etc to find out where the biggest performance improvements could be had.

Possibly the nicest Node.js beginner’s guide (and style guide)

Felix Geisendörfer, one of the node.js contributers has released what can only be dubbed as the ultimate guide to writing node.js applications. He’s launched a site called nodeguide.com which has a beginner’s guide, a guide for how to convince your boss you should be using node (kind of funny, but sadly there are people who need this) and a style guide for standardization of indentation, naming, etc which should be taken with a grain of salt.

Echo JS launched

A new Hacker News-style social news site has been launched focused exclusively around Javascript. It’s a nice source for some interesting JS libraries and articles.

If you are passionate about Javascript, you should check it out:

http://www.echojs.com/

New Vodafone in Iceland website launched

The Vodafone website in Iceland has just undergone a redesign. It was designed by the amazing web agency Kosmos & Kaos, which is also based in Iceland.

I’m very grateful to have been able to partake in the project. I helped with the CSS, initial HTML and most of the Javascript interactions on the website, and I’ve got to say I’m pretty proud of the work. That includes some nice CSS3 effects, a custom parallax slider, the modern dropdown menu etc.

Which Javascript Templating Engine Should You Use

You may know John as the author of jQuery, so this fellow really knows what he’s doing when it comes to Javascript. John’s templating engine is extremely fast. In fact it’s the fastest of the templating engines featured on this jsPerf benchmark comparison test. What’s more amazing is if you view the code behind it, it is extremely short and simple which also means that it minifizes pretty easily to just under 500 characters. That’s impressive.

Cleaning user input/output with javascript and node.js

I was trying to find a good function/library which I could use to sanitize HTML using Javascript.

Like many before me, I’ve spent a good number of programming hours/days/weeks in the past trying to write my own regular expressions to do this. But I wouldn’t wish it on my worst enemy to do that ever again. The techniques for XSS are many and advanced and you’ll be fighting an uphill battle if you think you can “roll your own”.

I wanted to do it both on the client side as well as the serverside (node.js). After some wasted time googling around I posted a question on stack overflow and found out that there are a number of good libraries out there.

Where’s your logic?

Ok, this is my first blog post here, so it probably sucks. If you value your time, don’t read this. When writing code these days, I keep running into these dilemmas. With the way the web and application development has been evolving, a greater part of the development and more importantly my time, goes into [...]