The first official jQuery event in Europe took place in Oxford on friday February 10 2012. I was there, interested in learning more about jQuery in my quest towards becoming a jQuery master. It also seemed like a good opportunity to measure my skills to those of my peers.
I attended 11 presentations, 3 of which I liked the best and will discuss here.
‘Contextual jQuery’ by Doug Neiner
Doug discussed writing code contextually rather than declaring as a better, more efficient way of writing jQuery. Some examples:
- Delegate events instead of the traditional $(selector).click()
- Using traversing, for example: .closest() instead of .parent()
- Use functions, so you don’t repeat code
- Don’t make your JS dependent on edits in your HTML
- Use as few selectors as possible in document ready
The main advantage of coding contextually is that the code is much easier to manage en makes better use of the available resources. Apart from that, the size of the code is often smaller because code can be re-used.
A tip for making better use of resources is loading script parts when they’re needed: users usually don’t use a page in full, so there’s no reason the load all code initially. For example, the script for a contact form can be loaded only when a user focus on a form field. As long as he or she hasn’t, you can expect the form doesn’t need to be send.
Doug also talked about how we don’t always need to pick the fastest option perfomance-wise: the decision between a fast (and harder to maintain) and a slower (but easier to maintain) method is completely dependant on the situation. When something needs to be executed at load is usually best to go for fast in order to have a quick a pageload as possible. But when a code snippet needs to be executed after a click, it’s probably better to go with the solution that’s easier to maintain – these type of scripts usually don’t need to be performed several times over, so the few extra miliseconds shouldn’t be a problem.
You can view Doug’s presentation.
‘Web vs. Apps’ by Dion Almaer & Ben Galbraith
Dion and Ben was by far the most entertaining as they’re good story-tellers. They talked about the pros and cons of webapps vs native apps. They provided examples from their own experience in working for clients like Wal-Mart.
What I got out of the presentation is there’s pros and cons to both webapps and native apps, and that the decision mainly depends on the specific target audience and project goals. Also, Dion and Ben believe that both can co-exist, especially when the overlapping parts can be maintained in the same development environment, for example with PhoneGap or similar software.
An obvious advantage native apps have over webapps is that they currently have much more possibilities in terms of device usuage. They can for example use the devices camera or address book, something that’s not (yet?) possible with webapps.
‘jQuery Mobile’ by Todd Parker
Personally I haven’t had much experience with jQuery Mobile, I thought it was simply a template based platform for easier mobile development. As it turned out, jQuery Mobile is much more than that – it includes many handy tools for mobile development such as ajaxifying links in combination with smooth transitions.
Todd’s talk wasn’t just interesting because of everything I learned about jQuery Mobile but also because of the insight he shared on developing and testing websites for mobile devices. I’ve been working on several responsive websites recently, so I did a fair share of testing on mobile devices. Most of it on the iPhone 3 and 4, as I figured they’d cover most of the mobile usuage as for example Android browsers are quite similar to iOs browsers. After attending various keynotes it became clear to me that Android browsers are much more different from Safari on iOs than I’d realized. Todd told us they in fact test on 40 different devices and operating systems! While that might be slightly overdoing it when it comes to testing mobile websites, it does make sense at least to test on a Windows Phone, Blackberry, iPhone and Android phone. And then there’s the various versions of operating systems and browsers… Serious testing for mobile is a time-consuming activity.
I’ve learned a lot on the jQuery event in Oxford, and there’s a variety of things I intend to find out more about. Finally, I feel reassured that I am going in the right direction in terms of webdevelopment.