Simon Willison’s Weblog

Subscribe
Atom feed for javascript

689 items tagged “javascript”

2008

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

Let me be again clear here that Comet isn’t a new single technique. Rather, it’s a combination of existing push technologies with further research into new methods that together provides a robust framework for pushing data to all clients on modern networks.

Michael Carter

# 3rd February 2008, 10:04 pm / michael-carter, comet, javascript

Blob Sallad—canvas tag and JavaScript physics simulation experiment. Björn Lindberg provides a detailed code walkthrough of his brilliant canvas demo, inspired by Loco Rocco.

# 26th January 2008, 12:25 pm / locorocco, javascript, canvas, opera, bjornlindberg, tutorial, physics

jQuery.ScrollTo (via) Neat jQuery plugin for animated scrolling of both windows and overflow elements.

# 21st January 2008, 9:53 pm / jquery, javascript, scrollto, scrolling, animation, plugins

Dangers of remote Javascript. Perl.com got hit by a JavaScript porn redirect when the domain of one of their advertisers expired and was bought by a porn company. Nat Torkington suggests keeping track of the expiration dates on any third party domains that are serving JavaScript on your site.

# 20th January 2008, 9:49 am / perldotcom, oreilly, nat-torkington, javascript, security, domains, xss

Automate firing of onload events. Paul Irish suggests setting up your site’s onload handlers in a single external JavaScript file then executing different handlers depending on the body element’s id attribute.

# 17th January 2008, 4:08 pm / javascript, paul-irish, onload

.first() and .last() methods for jQuery. I got fed up of expecting these to exist, so I wrote them as a couple of one-liner plugins.

# 16th January 2008, 9:41 pm / jquery, plugins, javascript

jQuery 1.2.2: 2nd Birthday Present. The API stays the same, but there are some healthy speed improvements, a new way of adding custom events and (most importantly) .ready() now waits for the CSS to be ready in addition to the DOM.

# 15th January 2008, 8:59 am / css, dom, javascript, jquery, libraries, documentready, ondomcontentloaded

Javascript CSS Selector Engine Timeline. It’s not every day you see a piece of code you wrote compared to a Ford Pinto :)

# 14th January 2008, 1:25 pm / fordpinto, funny, javascript, css