Posts Tagged ‘jQuery’

Speeding up jQuery’s each function

In my previous post, “Investigating JavaScript Array Iteration Performance“, I found that among a selection of different array iteration methods, jQuery’s each function was the slowest. It’s worth mentioning again that these investigations are pretty academic – array iteration and looping speed is unlikely to be the source of performance problems compared to actual program logic, DOM manipulation, string manipulation, etc. I just found it interesting to poke into how things work in different browsers. That said, with the recent release of jQuery 1.4 emphasizing performance so much, I wanted to see what if anything could be done to speed up each (which is used inside jQuery all over the place), and whether it would made much of a difference.

Again, the details are after the jump.
(more…)

Investigating JavaScript Array Iteration Performance

The other day I was working on some JavaScript code that needed to iterate over huge arrays. I was using jQuery’s $.each function just because it was simple, but I had heard from a bunch of articles on the web that $.each was much slower than a normal for loop. That certainly made sense, and switching to a normal for loop sped up my code quite a bit in the sections that dealt with large arrays.

I’d also recently seen an article on Ajaxian about a new library, Underscore.js that claimed to include, among other nice Ruby-style functional building blocks, an each function that was powered by the JavaScript 1.5 Array.forEach when it was available (and degrading for IE). I wondered how much faster that was than jQuery’s $.each, and that got me to thinking about all the different ways to iterate over an array in JavaScript, so I decided to test them out and compare them in different browsers.

This gets pretty long so the rest is after the jump.
(more…)

360Voice.com Challenges Windows Sidebar Gadget

In my post introducing the Bungie Card Windows Sidebar Gadget I mentioned that I was making one more gadget that would be of somewhat more limited interest. Well, I’m finally finished with it: the 360Voice.com Challenges gadget! 360Voice.com is a fun little site that started off by giving your Xbox 360 a blog that would summarize each day’s gameplay. It’s since grown far beyond that, but the feature I like most is the “challenges“. Challenges are a little meta-game where you get some friends together and see who can win the most gamerscore via unlocking achievements over a set period of time.

I do a lot of these challenges, so I wanted to be able to keep track of their progress on my sidebar. The gadget shows you the time left in the challenge, the current standings, and the “live score”, which is the gamerscore each player has earned that day that hasn’t been counted in the official standings yet (gamerscore is sampled by 360Voice.com at midnight PST each day). Once the challenge is over, the winner is given a little crown and the gadget waits for the next challenge.

Fortunately, the 360Voice.com developers had the good sense to provide an XML web services API to their challenge data (and a lot of other stuff too!) so it’s not too hard to make cool things like this gadget that tie into their site. For this project I went ahead and included my favorite JavaScript library, jQuery, and a neat jQuery-based databinding library called chain.js. Using these made development a lot smoother – the old familiar Sidebar bugs and Internet Explorer weirdness was still there, but overall it wasn’t too bad. I’ve specifically designed it to be as light as possible on 360Voice.com’s API too, so hopefully it won’t impact their service.

I think this is the most attractive gadget I’ve made – it’s certainly the most data-rich. I’m really proud of how it came out. I hope everybody enjoys it, and if you haven’t ever done a 360Voice challenge, go start one! Also, if you like it, please rate it at Windows Live Gallery.

P.S.: While I was monkeying around with gadgets, I’ve made some minor changes to my Top Process gadget – the text-fade option is no longer there since it really didn’t add anything, and I may have fixed a couple minor bugs.

Posts I haven’t written

I haven’t been updating this blog too much recently. I never meant for this blog to run on a schedule, but I did intend to post more frequently than this. My original idea was that the blog would serve two major purposes. First, it is a place for me to announce new projects or updates to software and websites I’ve already released. It’s done that quite well, though I haven’t had much to announce recently. My job has been taking the majority of my development time, and most of the projects I’ve been working on at home are either private or haven’t been released in the form I’d like to because my employer hasn’t approved them for release yet.

The second major purpose for my blog is as a place for me to record the solution to problems I run across while developing software, so that others won’t have to spend hours Googling or using trial and error to come to the same conclusion. I didn’t intend to rehash things that were easily found or that had already been discussed – only to post when I felt it was something that added value to the internet that hadn’t been there before. So a lot of the blog posts are not really a narrative or running commentary – they’re not meant to be subscribed to, but found individually. It’s for this reason that my most popular posts tend to include the exact text of error messages. This type of post has suffered both because I haven’t been doing as much development, because I can’t discuss a lot of what I’ve learned due to the nature of the projects I’m working on, and because I’ve been learning new stuff (like Ruby on Rails) and haven’t done enough to have solved problems others haven’t already posted solutions for.

The third reason I have this blog is to occasionally talk about my thoughts on different technical topics, from web development to video games. Again, I don’t like to make a post unless I think I’m adding something new, and most of the topics I’ve wanted to talk about have already been covered. I had a lot of draft posts sitting around about web development, web standards, and the evolution of browsers, but then I discovered Alex Russell’s blog and it turns out he’s already said most of what I wanted to say, and better than I could. Other stuff, like my impressions of Windows Vista, critique of stackoverflow.com and suggestions for the Xbox Live Arcade lineup, have been covered to my satisfaction in plenty of places. Maybe some of them will end up posted, but probably not.

Another part of the reason I haven’t posted much is the sheer weight of unfinished posts I have. Right now I have 64 drafts and only 52 real posts! So I’m going to attempt to clear things out by writing a little about what I haven’t posted. A lot of this stuff wasn’t posted because it fell under that third point above, but some of it I was just too lazy to flesh out into real posts. Some of it’s just random stuff. So here’s what’s been happening in the last year:

(more…)