Ian Nicholas

Serializing Complex Python Data to JSON

Python has a JSON module that can serialize simple data structures like dictionaries to a JSON string. This comes in handy when you're serving up some content through AJAX. Unfortunately, your fancy Python data structure will sometimes contain objects that don't fit easily into JSON, and the parser won't even try to work with it.

Read more

Hover Is Dead; Long Live Hover

Is it just me, or have some of the visitors lately been a little… well… spooky. They drop in, scroll around a bit like normal, but then—somehow, with no warning at all—we're clicked on. It's disorienting. Their sneaking up on us wouldn't bother me so much, really, but… I could swear there are more of them every day.
—a :hover to its a element

Yes, it's a scary time to be a hover state. The venerable CSS selector and the JavaScript events that sprang from it have seemingly always been here, fully supported by nearly every browser out there. But there are some new kids on the block, and these upstart smartphones and tablets think it doesn't even exist. To them, there's no such thing as a hover. Interacting with a page element is a purely binary proposition—you are not touching it, and then you are.

Read more

Pacing Your JavaScript with Pseudo-Threaded Closures

Thanks to <a href="http://expositionfairy.tumblr.com/" rel="external">expositionfairy</a>.

Many Web developers are guilty of throwing a truckload of JavaScript work at the browser at one time or another, assuming that since none of it is hitting a server, there's no need to worry about performance. And considering how browsers have lately become adept at turning around shocking amounts of JavaScript work in short order, the client-side bottleneck is just not something we have to wrestle with often.

But it is still most certainly a bottleneck, and too many websites have taken to gleefully dumping untenable processing loads on their visitors' computers. You've probably seen it: pages that load up quickly, then lock for a second or longer, preventing you from scrolling, as the browser churns through a backlog of social plugins, videos, and other intensive objects. In a modern browser like Chrome, it's simply annoying, but if you're using an old version of IE, you'd might as well work on your novel between page loads.

Read more