Simon Willison’s Weblog

Subscribe
Atom feed for javascript

702 items tagged “javascript”

2008

Session variables without cookies. Brilliant but terrifying hack—you can store up to 2 MB of data in window.name and it persists between multiple pages, even across domains. Doesn’t work with new tabs though, and storing JSON in it and eval()ing it is a bad idea—a malicious site could populate it before sending the user to you.

# 13th May 2008, 9:59 pm / javascript, json, crossdomainstorage, sessions, security

Hey Google: any chance we can all build the social web together without requiring JavaScript?

Me

# 13th May 2008, 1:49 pm / me, twitter, google, javascript

Persevere adds Comet Support. Persevere sounds neat: a RESTful HTTP/JSON data store (the interface reminds me of CouchDB) which recently gained the ability to “subscribe” to a resource and receive notifications of updates via comet.

# 13th May 2008, 8:09 am / persevere, comet, javascript, json, rest, restful, couchdb

Processing.js. John Resig’s outstanding port of the Processing visualisation language to JavaScript and Canvas. Runs amazingly well in Firefox 3. One hell of a hack.

# 9th May 2008, 8:24 am / processing, john-resig, javascript, canvas

Unobtrusive JavaScript with jQuery. The online handout for the tutorial I gave this morning at XTech.

# 6th May 2008, 6:53 pm / jquery, javascript, handout, xtech, xtech08, unobtrusive-javascript

Reading binary files using Ajax. There’s a simple trick for Firefox, and (amazingly) you can get IE to play along using a function written in VBScript.

# 22nd April 2008, 7:02 pm / binary, ajax, ie, firefox, vbscript, javascript, xmlhttprequest

Embedding custom non-visible data in HTML 5. “Every HTML element may have any number of attributes starting with the string ’data-’ specified, with any value.”—this will be incredibly useful for unobtrusive JavaScript where there’s no sensible place to store configuration data as HTML content. It will also mean Dojo has an approved method for adding custom attributes to declaratively instantiate Dojo widgets.

# 19th April 2008, 10:58 pm / html5, javascript, standards, unobtrusive-javascript, html, dojo, customattributes

JavaScript: The Good Parts. Douglas Crockford’s soon-to-be-published book on the subset of JavaScript that he recommends. Promises to be “short, but dense”—if it’s half as good as his JavaScript lectures this is going to be a must-have.

# 19th April 2008, 4:38 pm / javascript, douglas-crockford, books

Comet at the Highland Fling. I thoroughly enjoyed the Highland Fling yesterday. Here are the slides from my talk on Comet.

# 4th April 2008, 10:13 am / comet, highlandfling08, talks, conferences, javascript

Implementing a syntax-higlighting JavaScript editor in JavaScript. Appropriately subtitled “a brutal odyssey to the dark side of the DOM tree”. Some seriously clever trickery going on here.

# 4th April 2008, 8:27 am / javascript, syntaxhighlighting, dom

Advanced JavaScript Debugging Techniques. There’s more to JavaScript debugging than just Firebug.

# 4th April 2008, 7:51 am / firebug, javascript, debugging, sitepen

Brendan Eich: Popularity. I never knew that Brendan went to Netscape on the promise of “doing Scheme in the browser”.

# 4th April 2008, 7:30 am / brendan-eich, javascript, scheme, netscape

Classy Query. Beautifully implemented parody of class-based JavaScript and verbose namespacing as a jQuery extension, from John Resig. The source code has some neat tricks in it, in particular the buildClass() function.

# 1st April 2008, 9:48 am / john-resig, namespacing, jquery, javascript, parody, funny, aprilfools

getElementsByClassName pre Prototype 1.6. Older releases of Prototype break in Firefox 3 and Safari 3.1 due to unsafe namespace management—getElementsByClassName is now a browser built-in but with different semantics to the Prototype method of the same name. Prototype 1.6 is fine.

# 26th March 2008, 8:28 am / getelementsbyclassname, javascript, john-resig, firefox3, namespaces, prototype, safari

Firebug + Dijit tips. News to me: Firebug has a magic $1 variable which corresponds to the currently selected node. Very handy.

# 17th March 2008, 2:08 am / firebug, javascript, debugging, dojo, dijit

dojox.gfx demos. Impressive demos of the Dojo 2D drawing APIs—these need to be linked from the dojo site, it took me quite a while to find them.

# 16th March 2008, 4:24 pm / dojo, dojox, gfx, javascript, drawing, 2d

JavaScript in Internet Explorer 8. John Resig’s analysis. News to me: IE 8 doesn’t support the W3C event model—I had assumed that would be a priority.

# 6th March 2008, 11:59 pm / javascript, ie8, john-resig, standards

Internet Explorer 8 Readiness Toolkit. The new built-in development tools look similar enough to Firebug to make me very happy. Also of interest: Selectors API (for fast getElementsBySelector), CSS 2.1 support, support for XHTML style namespaces in HTML, an interesting Web Slices feature based on the hAtom microformat and 6 connections per host (up from 2) which should make Comet easier.

# 5th March 2008, 6:28 pm / comet, javascript, css, standards, ie8, selectors, namespaces, hatom, microformats

Acid3 is out. The third Acid test, again compiled by Ian Hickson. This one viciously tests DOM Scripting standards compliance and currently exposes flaws in every browser.

# 5th March 2008, 12:34 am / javascript, ian-hickson, acid3, standards, web-standards-project

CouchDB, XML, and E4X. Brilliant—CouchDB now enables SpiderMonkey’s E4X support, meaning CouchDB views can easily query XML documents stored inside JSON objects using E4X syntax.

# 5th March 2008, 12:31 am / couchdb, javascript, xml, e4x, json, spidermonkey, christopher-lenz

Gears 0.2 Released! New modules are HttpRequest and Timer, both for use within workers (which provide Erlang-style message passing concurrency). Particularly interesting is that the Gears HttpRequest module can be used for much cleaner Comet implementations in IE.

# 5th March 2008, 12:21 am / ie, google-gears, comet, javascript

xssinterface (via) Clever JavaScript library for implementing opt-in cross-domain messaging in JavaScript (allowing communication between pages and iframes on different domains). Uses HTML 5’s postMessage API if available, otherwise falls back on either Google Gears or a clever cookie hack.

# 5th March 2008, 12:08 am / xssinterface, crossdomain, javascript, html5, postmessage

jQuery 1.2 Cheat Sheet. Handy. It helps that most of jQuery’s method names are pretty much self explanatory once you’ve been using the library for a couple of weeks.

# 10th February 2008, 9:12 pm / jquery, javascript, cheatsheet, gscottolson

Event Delegation Made Easy. Dan Webb demonstrates a neat trick for event delegation in jQuery, using CSS selectors and the jQuery .is() method to dispatch to different callbacks from a single event handler based on the target of the event.

# 10th February 2008, 3:13 pm / eventdelegation, jquery, javascript, dan-webb, delegation

Transitioning from Java Classes to JavaScript Prototypes. Peter Michaux shows how JavaScript’s prototypal inheritance can run rings around traditional Java-style classes once you figure out how to take advantage of it.

# 10th February 2008, 3:10 pm / javascript, prototypalinheritance, java, classes, inheritance, pete-michaux

Cross-Window Messaging. Now in Firefox 3 trunk, the HTML 5 specified ability for JavaScript to send messages between windows (or iframes) hosted on different domains. Fantastically powerful, but must be implemented with care to avoid accidentally processing bad messages from malicious third parties.

# 10th February 2008, 12 pm / firefox, firefox3, crosswindowmessaging, javascript, john-resig, html5

querySelector and querySelectorAll. WebKit now supports the W3C Selectors API. Expect the various JavaScript libraries to add this as an optimisation to achieve massive speedups (Prototype are already working on it).

# 8th February 2008, 11:21 am / prototype, javascript, safari, webkit, w3c, selectors, libraries, queryselector

Low Pro For jQuery? Dan Webb on why he prefers Prototype over jQuery: “The one big reason was that, while jQuery was super simple and concise when working on smaller projects, it offered no help in structuring larger applications”.

# 3rd February 2008, 10:16 pm / dan-webb, prototype, jquery, javascript, libraries, lowpro

Faster JavaScript Trim. Neat optimisation post—it turns out that while regular expressions are great for removing leading whitespace you can do a lot better at trailing whitespace by manually looping backwards from the end of the string.

# 3rd February 2008, 10:12 pm / whitespace, trim, javascript, optimisation, steven-levithan