707 posts tagged “javascript”
2007
The Art & Science of JavaScript. My first author credit: I’m contributing a chapter to SitePoint’s next JavaScript tome.
Using the jQuery test suite for your own projects. jQuery’s test suite has clever start(), stop() and expect() methods for running assertions within asynchronous code.
Global namespace pollution in IE. Another reason to avoid JavaScript global variables like the plague: IE creates a bunch of them for you which may well intefere with your own code.
Native DOMContentLoaded is coming to Safari. I filed this bug over two years ago. They’ve just committed the resulting patch to trunk.
Roll out your own JavaScript Interfaces. Dustin shows how to build a tiny jQuery-style (chainable) library that contains your own JavaScript convenience functions.
I have another technique [...] that I'll be switching jQuery to. If you attempt to insert into the document.body before the document is fully loaded, an exception is thrown. I take advantage of that to determine when the document is fully loaded.
DOMContentLoaded for IE, Safari, everything, without document.write. Stuart has taken Hedger’s recent IE technique, combined it with the others and compressed it in to a short-as-possible code snippet that you can paste in to your scripts without having to include the whole of jQuery/YUI/Dojo/Prototype.
IEContentLoaded. An alternative method of detecting DOMContentLoaded on IE; works by polling until the doScroll() method on an unattached element stops throwing errors.
Hello JS-CTYPES, Goodbye Binary Components. Mark Finkle is porting Python’s ctypes functionality to the Mozilla platform, to allow binary XPCOM components to be defined in pure JavaScript.
Apparently if you try to remove/destroy/trash a FORM dom node in IE6, it won't delete it, instead creating a bizarre orphaned node stuck sucking up memory until the browser window is refreshed.
ActsAsUndoable. Lawrence Carvalho shows how robust undo functionality can be added to a JavaScript application through careful application of the Memento design pattern.
The Elements of JavaScript Style. Douglas Crockford illustrates better coding practises through refactoring of old code.
jQuery 1.2. Lots of neat new stuff; my favourite new feature is “Partial .load()” which lets you pull in HTML with Ajax and then use a CSS selector to grab a subset of that page and inject it in to the DOM.
Google Maps API gets clickable polylines and polygons. Interesting explanation of how they optimised calculating the distance to the nearest point on a polyline.
Protoscript (via) JavaScript tool designed for easy prototyping of JS interactions; powered by YUI and jQuery.
HTTPOnly cookie support in Firefox. Five years after the bug was filed, HTTPOnly cookie support has gone in to the Mozilla 1.8 branch. This is a defence in depth feature that has been in IE for years—it lets you set cookies that aren’t available to JavaScript, and hence can’t be hijacked in the event of an XSS flaw.
CouchDb: Some Context. CouchDb developer Jan Lehnardt wrote up detailed notes on slides from a presentation he gave back in June, explaining most of what’s interesting about CouchDb (although without the new JavaScript function query language).
CouchDB: Thinking beyond the RDBMS. CouchDB is a fascinating project—an Erlang powered non-relational database with a JSON API that lets you define “views” (really computed tables) based on JavaScript functions that execute using map/reduce. Damien Katz, the main developer currently works for MySQL and used to work on Lotus Notes.
Freebase. Out of closed beta, although you still need an invite code to contribute. I hope they drop the JavaScript requirement for viewing content on the site.
Google Web Toolkit: Towards a better web. Good overview of why GWT exists, but I take exception to the title: requiring JavaScript to even display something does not make the web “better”.
jQuery 1.1.4: Faster, More Tests, Ready for 1.2. The backwards compatibility policy for 1.2 is pretty clever: provide a plugin that restores removed functionality (such as XPath selectors).
Building a JavaScript Library. Slides from John Resig’s Google Tech Talk. Some great tips in here, including: make your APIs orthogonal, look for common patterns, keep things extensible and write the documentation yourself.
Live Query jQuery plugin. Ingenious plugin that lets you register jQuery event bindings to be executed when a new element matching the provided selector is added to the DOM. Performance is kept snappy by only running the check after a jQuery DOM manipulation method has been executed (append, prepend, attr etc); it won’t notice elements added using regular DOM methods.
Fixing GC issues on IE 6: New IE download. Microsoft have released Windows Script Host / Script Runtime version 5.7, which apparently cleans up a bunch of IE 6 memory leaks.
Learning jQuery. An entire year’s worth of jQuery tutorials, split in to beginner, intermediate and advanced.
Operation Aborted. Another fantastically obscure IE bug: appending new elements to the HEAD element breaks if a BASE tag is present.
Prototype 1.6.0 release candidate. Prototype gets a long-needed update to its Event API, and some interesting new Function.prototype extensions.
Some Notes on the YUI Rich Text Editor. Dav Glass explains how he achieved the impressive feat of building a rich text editor widget that also works in Safari.
Lazy Function Definition Pattern. Neat JavaScript trick: redefine a function the first time it’s called, for example to switch in different browser implementations based on object detection.
jQuery for JavaScript programmers
When jQuery came out back in January 2006, my first impression was that it was a cute hack. Basing everything around CSS selectors was a neat idea (see getElementsBySelector) but the chaining stuff looked like a bit of a gimmick and the library as a whole didn’t look like it would cover all of the bases. I wrote jQuery off as a passing fad.
[... 2,608 words]