background preloader

Javascript

Facebook Twitter

Graphics

Node.js. Backbone.js. Main Page. How to not suck at jQuery : programming. Engineering: jQuery the Right Way. jQuery has changed the way we write Javascript by abstracting out much of the painful cross-browser implementation details that used to plague developers, but to use it correctly still requires a little knowledge about what’s going on under the hood. In this post we’ll take a good look at jQuery’s selectors and how to use them efficiently. I’ll also talk briefly about DOM manipulation and event handlers. Part 1: Search At its core jQuery is exactly what its name implies, a query engine designed for search. And just like you’re careful to construct efficient SQL queries, you need to take the same care with your jQuery selectors. Ego and #ID You’re right, it’s never that clear cut Good browsers actually provide a getElementsByClass which greatly improves the performance of class selectors.

Pseudo selectors provide a lot of power in the right situations but they’re also a lot slower. See? Narrowing the search Good semantics, good selectors Luckily this isn’t hard to do. Part 3: A note on events. A crash course in how DOM events work - Jupiter JavaScript Consulting. DOM events are something that web developers often take for granted, especially with libraries like jQuery.

A crash course in how DOM events work - Jupiter JavaScript Consulting

The complexity and low-level mechanics of events are abstracted away. As far we’re concerned, snippets like the following: $('button').click(function(){ console.log('Hello!') ; }); just work, and it’s magic. There are three parts to this article: How to listen for an event How events move through the document What the browser is actually doing How to listen for an event There are three ways to listen to an event. DOM Level 0 This is the simplest way of defining an event handler. <button onclick="alert('hello!') This approach is highly discouraged. DOM Level 1 Setting a DOM Level 1 event handler provides a bit more flexibility than DOM Level 0. Document.getElementById('myButton').onclick = function(){ alert('Hello!') This approach separates our JavaScript from our HTML, which is great. DOM Level 2 - Event listeners The remainder of this article applies exclusively to DOM Level 2 events. 1.

Douglas Crockford on JavaScript and HTML5. SAN FRANCISCO, California — When Doug Crockford first encountered JavaScript, his first impression was that it was “one of the most incompetent pieces of software engineering [he'd] ever seen.”

Douglas Crockford on JavaScript and HTML5

His opinion, which is highly regarded since he’s widely considered to be the grand poobah of JavaScript, is one that was shared by many in the web’s early days. However, as the language has grown and the era of the web app is in full swing, it’s reaching a new level of success far beyond what he (or anyone) could have predicted. The video above, shot here yesterday at the Web 2.0 Expo by the conference organizers at O’Reilly Media, compresses several of Crockford’s thoughts on JavaScript and HTML5 into five minutes. He has hope for HTML5, but he has issues with the way it’s being developed. Primarily, he’s concerned that there are too many security holes, and that “there’s too much kitchen sink in HTML5″ — excessive duplication of the elements and not enough discipline in the code. See Also: Interactive tutorial. JavaScript Guide - MDC.

The JavaScript Guide shows you how to use JavaScript and gives an overview of the language.

JavaScript Guide - MDC

If you want to get started with JavaScript or programming in general, consult the articles in the learning area. If you need exhaustive information about a language feature, have a look at the JavaScript reference. Chapters. HTML, CSS, and Javascript from the Ground Up - Google Code University - Google Code.