Category: Scripting

Best Practice for Creating Custom Elements

It looks like cus­tom ele­ments, and web com­po­nents in gen­er­al, are begin­ning to break through into gen­er­al devel­op­er con­scious­ness, as I see more and more arti­cles and talks dis­cussing what they are, what they are good for, and how to make them.

As they’re not yet being used heav­i­ly in devel­op­ment, how­ev­er, I think there’s a good oppor­tu­ni­ty to define best prac­tices in the way we use them. In this post I want to pro­pose a best prac­tice method for writ­ing cus­tom ele­ments: I’ll do that by com­par­ing two meth­ods for cre­at­ing cus­tom ele­ments, along with the advan­tages and draw­backs of each.

Aside: it strikes me that I haven’t writ­ten about cus­tom ele­ments here on my own blog, despite hav­ing giv­en a few talks and writ­ten a few pub­lished arti­cles on the sub­ject. In case you’re not sure what they are, I rec­om­mend you read my Detailed Intro­duc­tion To Cus­tom Ele­ments first.

Read the full article

Video of some recent talks I’ve given

I’ve had a real­ly busy year for pub­lic speak­ing, hav­ing had the plea­sure of being invit­ed to speak at ten events so far, from local grass­roots meet­ings to pro­fes­sion­al con­fer­ences (with more to come). Not all of the talks are record­ed but many are, so below I’ve select­ed a few videos from the last few months in the vain hope that you may find them interesting.

Read the full article

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



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