javascript Archives - Broken Links Archive

Removing anonymous event listeners

I recent­ly ran into a prob­lem involv­ing the removeEventListener() method, which caused me a good half an hour of con­fu­sion before a light­bulb appeared above my head and I was enlight­ened by a solu­tion — a solu­tion which, it must be said, is very obvi­ous in hind­sight. So doubt­less many peo­ple know this already, but I’m record­ing it here along with anoth­er approach I thought of after­wards, in the hope that they may be use­ful to some­one in the future.

Read the full article

Data Attributes in HTML and jQuery

Some­times the exist­ing HTML attrib­ut­es aren’t suf­fi­cient for describ­ing an ele­men­t’s con­tent. We can use class, ref, rel, title and more, but even so there are occa­sions where that’s not enough. HTML5 address­es this prob­lem with the intro­duc­tion of Data Attrib­ut­es, which allow you to add sim­ple meta­da­ta to indi­vid­ual ele­ments, large­ly for the pur­pose of pro­vid­ing infor­ma­tion to make JavaScript func­tions easier.

Read the full article

New jQuery release and Mobile Alpha

A new ver­sion of jQuery has qui­et­ly been released over the week­end. It’s only a minor point release but has a cou­ple of fea­tures which look amaz­ing: some selec­tor func­tions now work up to 8x faster than the pre­vi­ous release; and there is sup­port — very clever sup­port — for HTML5 data attrib­ut­es. Take a look at the jQuery 1.4.3 release notes for more.

Also released was the first alpha of jQuery Mobile, a touch-opti­mised amal­gam of jQuery and jQuery UI. It’s actu­al­ly a lit­tle bug­gy on my Galaxy S Android phone, but as it’s an alpha release that’s per­fect­ly for­give­able. It looks pret­ty smart and comprehensive.

JavaScript: The Selectors API

JavaScript libraries like jQuery and Pro­to­type are amaz­ing; flex­i­ble and pow­er­ful, they stan­dard­ise process­es and make cross-brows­er script­ing real­ly easy. I rarely work on a project nowa­days where a library isn’t used.

Their ease-of-use has a slight draw­back, how­ev­er: it’s easy to rely on them too much, and lose sight of new devel­op­ments in JavaScript. This was the rea­son for my not real­ly pay­ing much atten­tion to an excit­ing recent intro­duc­tion, the Selec­tors API, until I had cause to use it on a per­son­al project.

Read the full article

Using SVG in CSS with JavaScript detection

With the release of IE9 and Fire­fox 4 all major browsers are going to sup­port using SVG in the img ele­ment or as a CSS back­ground image, which is great news as SVG images are good for high def­i­n­i­tion, scal­able web­sites. I’ve writ­ten a cou­ple of posts recent­ly about using SVG with the background-image prop­er­ty, and how to cope with browsers that don’t sup­port it. The method I came up with works, but is far from ele­gant; for one thing, it does­n’t allow for transparency.

Anoth­er approach we can take to the prob­lem is to use JavaScript to detect SVG sup­port. Alex­is Dev­e­ria wrote a script which detects if your brows­er sup­ports SVG and, if not, replace the images with PNG. It’s a good script, but I won­dered if there was an alternative.

Read the full article

My Name In Print

I hope you’ll for­give a lit­tle self-pro­mo­tion, as I’d just like to play a few quick notes on my own trum­pet. The lat­est issue of Net mag­a­zine is now on sale, and fea­tures a tuto­r­i­al arti­cle, Cre­ate A Dynam­ic Con­tent Pan­el, writ­ten by me.

In the arti­cle I explain how to build a dynam­ic Con­tact area, as we did on our recent redesign of, using the Web Stor­age API and the BBC’s Glow Javascript library.

I’m not sure what the rights sit­u­a­tion is with this arti­cle, but I hope that at some point in the future I’ll be able to post it here on my blog. But in the mean­time, you can buy a copy of Net mag­a­zine in the UK at all good newsagents, as the say­ing goes (I don’t know if it will be in over­seas edi­tions also).

Printed TutorialPrinted TutorialPrinted Tutorial

On the sub­ject of print, I’m also cur­rent­ly writ­ing a book about CSS3 which should be pub­lished lat­er this year. I’ll have more infor­ma­tion on that near­er the time.



I’ve updat­ed my Speak­ing page to include more con­fer­ences, more videos, and a lit­tle on my speak­ing require­ments and pref­er­ences. I’m plan­ning to cut down on the num­ber of talks I give in 2014 (twelve is too many), but am always open to inter­est­ing offers and oppor­tu­ni­ties, so please get in touch if you’re organ­is­ing an event.

[#] 1 Comment . More Asides.