Simon Willison’s Weblog

Subscribe
Atom feed for javascript

689 items tagged “javascript”

2009

Special Events in jQuery. How to add a custom “tripleclick” event to jQuery, using the jQuery.event.special extension hook.

# 30th March 2009, 10:15 am / jquery, javascript, events, brandon-aaron

Building Fast Client-side Searches. Flickr now lazily loads your entire contact list in to memory for auto-completion. Extensive benchmarking found that a control character delimited string was the fastest option for shipping thousands of contacts around as quickly as possible.

# 19th March 2009, 3:35 pm / flickr, javascript, autocomplete, ajax, json

A few notes on the Guardian Open Platform

This morning we launched the Guardian Open Platform at a well attended event in our new offices in Kings Place. This is one of the main projects I’ve been helping out with since joining the Guardian last year, and it’s fantastic to finally have it out in the open.

[... 839 words]

Combine JSONP and jQuery to quickly build powerful mashups. jQuery’s JSONP support is one of my favourite little-known features of the library.

# 3rd March 2009, 3:17 pm / jquery, json, jsonp, javascript

jQuery Sparklines. Delightful Sparklines implementation, using canvas or VML in IE. A neat nod towards unobtrusiveness as well: you can specify your data as comma separated values inside a span, then use a single jQuery method call to convert the span in to a sparkline image.

# 27th February 2009, 8:43 pm / gareth-watts, graphs, canvas, javascript, jquery, sparklines, vml

Magic properties make Firefox synchronously load the Java plugin. Even defining a function called sun() (or several other symbols) will trigger the Java VM to be loaded, dramatically hurting the performance of your page.

# 27th February 2009, 4:03 pm / firefox, java, performance, javascript, mark-pilgrim

The Cost of Accessibility. Drew McLellan comments on the seemingly inevitable march towards JavaScript dependent applications, and argues that JavaScript frameworks such as Cappuccino have a duty to integrate accessibility in to their core.

# 25th February 2009, 10:31 pm / drew-mclellan, accessibility, cappuccino, javascript

Oscars 2009: the interactive results | guardian.co.uk. My latest project for the Guardian, put together on very short notice. Updates live as the results are announced, and allows Twitter users to vote on their favourite for each category by sending a specially formatted message to @guardianfilm—jQuery and Ajax polling against S3 under the hood.

# 23rd February 2009, 2:19 am / twitter, projects, guardian, oscars, javascript, jquery, s3

I think you overstate the usefulness of the [jQuery Rules] plugin. Using this plugin, users are now limited by what selectors that can use (they can only use what the browsers provide - and are at the mercy of the cross-browser bugs that are there) which is a huge problem. Not to mention that it encourages the un-separation of markup/css/js.

John Resig

# 22nd February 2009, 11:11 pm / john-resig, jquery, javascript, css, selectors, jqueryrules, plugins

jQuery.Rule (via) jQuery plugin for manipulating stylesheet rules. For me, this is the single most important piece of functionality currently missing from the core jQuery API. The ability to add new CSS rules makes an excellent complement to the .live() method added in jQuery 1.3.

# 22nd February 2009, 5:53 pm / jquery, plugins, css, javascript, arielflesler

jQuery 1.3.2 release notes. Not just a bug fix—there are a number of subtle behaviour changes, including to the :visible/:hidden selectors and the appendTo/prependTo/*To family of methods. I strongly recommend testing and reviewing those changes before upgrading.

# 21st February 2009, 4:42 pm / jquery, javascript

Twitter Don’t Click Exploit. Someone ran a successful ClickJacking exploit against Twitter users, using a transparent iframe holding the Twitter homepage with a status message fed in by a query string parameter. Thiss will definitely help raise awareness of ClickJacking! Twitter has now added framebusting JavaScript to prevent the exploit.

# 12th February 2009, 7:56 pm / framebusting, javascript, security, clickjacking, twitter, chris-shiflett

Ehy IE8, I Can Has Some Clickjacking Protection? (via) IE8 has built-in protection against clickjacking, but it’s opt-in (with a custom HTTP header) and IE only. It turns out the usual defence against clickjacking (using framebusting JavaScript) doesn’t work in IE as it can be worked around with a security=“restricted” attribute on an iframe.

# 29th January 2009, 1:39 pm / clickjacking, ie, ie8, http, security, javascript, iframes

OCR and Neural Nets in JavaScript. John dissects the brilliant Greasemonkey script that solves simple captchas using the canvas element and HTML5’s getImageData API.

# 25th January 2009, 12 am / getimagedata, captcha, ocr, javascript, greasemonkey, canvas, john-resig

google-mobwrite. Neal Fraser’s terrifyingly clever differential synchronization algorithm (for SubEthaEdit-style collaboration over the web) is now available as an open source Python and JavaScript library.

# 24th January 2009, 11:55 pm / neal-fraser, mobwrite, google, open-source, python, javascript, collaboration, subethaedit

AJAX APIs Playground. Ferociously useful collection of executable and editable example code for all(?) of Google’s JavaScript APIs, including Google Maps and the increasingly interesting Visualization API.

# 22nd January 2009, 6:38 pm / google, javascript, ajax, google-maps, googlevisualization

jQuery 1.3.1 Released. Bug fix for 1.3, mainly browser compatibility issues. Of interest: jQuery no longer ship a packed version (where JS is used to further decompress a string), as their tests show that this reduces performance due to the overhead of the extra decompression. They still provide a YUI Compressor minified version.

# 22nd January 2009, 10:41 am / minification, jquery, javascript, performance

jQuery 1.3 and the jQuery Foundation. The IP for jQuery and jQuery UI now rests with the Software Freedom Conservancy (a smart alternative to setting up a brand new foundation), while Sizzle is a separate project looked after by the Dojo Foundation.

# 14th January 2009, 5:59 pm / jquery, javascript, jqueryui, sizzle, dojofoundation, software-freedom-conservancy

Sloppy—the slow proxy. Java Web Start GUI application which runs a proxy to the site of your choice simulating lower connection speeds—great for testing how well your ajax holds up under poor network conditions.

# 13th January 2009, 4:17 pm / ajax, javascript, performance, sloppy, java, javawebstart, proxy, richard-dallaway

Visualising Radio, pushing, not pulling. The BBC’s new radio player uses Comet over a Flash XMLsocket connection transport, with an ActiveMQ message queue behind the scenes. I’d like to know what server they’re using to broadcast out to the XMLsocket connections.

# 13th January 2009, 12:59 am / bbc, duncanrobertson, activemq, comet, flash, javascript, xmlsocket

A Snapshot of The Yahoo! Photos Beta (from 2006). Scott Schiller shares an internal retrospective on the Yahoo! Photos interface from 2006, which was years ahead of its time (they started building it before the term Ajax had even been coined). The material on memory management and event delegation is particularly interesting.

# 12th January 2009, 10:21 pm / eventdelegation, scott-schiller, yahoo, yui, yahoophotos, ajax, javascript

instanceof considered harmful (or how to write a robust isArray. JavaScript’s instanceof operator breaks when dealing with objects that may have been created in a different document or frame, since constructors are unique to each frame. Instead, you can check for arrays using the default Object.toString method which the JS spec guarantees will return [object Array].

# 12th January 2009, 10:55 am / arrays, javascript, instanceof, tostring, frames

Manage Amazon EC2 With New Web-Based AWS Management Console. Finally! I’m amazed it took Amazon so long to do this. Managing EC2 instances from a custom Firefox extension was pretty bizarre. It’s a very nice interface, built on top of YUI. Unfortunately you still have to manage your entire virtual server farm using a single shared Amazon account.

# 9th January 2009, 9:34 am / amazon, aws, ec2, cloud-computing, yui, javascript

2008

ReferenceError: console is not defined. Since Firebug 1.2 you need to call window.loadFirebugConsole() in order for console.log and friends to work.

# 23rd December 2008, 10:22 pm / firebug, firefox, javascript, debugging

Quickchoice—a Speed Dial clone (via) Lovely demonstration of the CSS transform property, as supported by modern browsers. The magic is all in the iframe { transform: scale(0.25, 0.25) translate(-1200px, -900px) }

# 23rd December 2008, 12:49 pm / speeddial, javascript, css, csstransform, iframes

jQuery: Changeset 5990. “Added a new liveQuery/event delegation hybrid method”. Lets you add events that continue to work as new elements are dynamically appended to the DOM, e.g. $(’div p.foo’).live(’click’, fn). Works by adding an event handler to the root document element itself and relying on event bubbling. I have to admit I preferred the earlier proposal of $(’div’).delegate(’p.foo’..), which feels like it should have much better performance—anyone know of a good plugin that supports this?

# 23rd December 2008, 12:22 pm / jquery, delegate, livequery, javascript, events

jQuery changeset 5985 (via) jQuery trunk has ditched browser sniffing in favour of feature testing, where a small suite of unit-test-like code blocks is used to detect whether a browser supports specific idioms. If the tests fail jQuery still makes assumptions about what the fix is, but it’s not hard to imagine the library eventually using code tests to ensure the fix will work as well.

# 22nd December 2008, 10:58 am / jquery, feature-testing, javascript

Someone asked for onbeforeunload, so I started fixing it. Then I found that there was some rot in the drywall. So I took down the drywall. Then I found a rat infestation. So I killed all the rats. Then I found that the reason for the rot was a slow leak in the plumbing. So I tried fixing the plumbing, but it turned out the whole building used lead pipes. So I had to redo all the plumbing. But then I found that the town's water system wasn't quite compatible with modern plumbing techniques, and I had to dig up the entire town. And that's basically it.

Ian Hickson

# 19th December 2008, 1:58 pm / ian-hickson, onbeforeunload, standards, whatwg, html5, javascript

Integrating Facebook Connect with Django in 15 minutes. Django authentication middleware that calls the Facebook REST API using a cookie set by Facebook Connect and checks if that person is your Facebook friend. Despite most of the magic happening on the server you still need Facebook’s JavaScript to set that cookie in the first place.

# 17th December 2008, 1:18 pm / facebook, facebookconnect, cookies, javascript, django, middleware