Thursday, July 28, 2011

Book Review: JavaScript Enlightenment

This week jQuery team member Cody Lindley self-published the book entitled JavaScript Enlightenment.

If you recall he wrote another great resource a year or so ago called jQuery Enlightenment.

As you've probably heard me talk about before, it is important for a jQuery developer to really know the JavaScript language. Thankfully Cody has written this book to aid in this learning process.

Who is the Target Audience of this Book?

The book targets developers who are already JavaScript Library User (jQuery, dojo, YUI, etc...) and seeks to deepen their knowledge and transform them into a JavaScript Developer.

The audience isn't intended for beginner JavaScript developers. There is an assumption that you somewhat familiar with using a JavaScript library. If you are a developer that wants to deepen your understanding of JavaScript then this book is for you!

If you do consider yourself a beginner JavaScript or jQuery developer then you might consider going over to appendTo's new learning site where they have free videos and exercises to guide you through learning these concepts.

What does the book Cover?

The book covers JavaScript 1.5 (also known as ECMA-262 Edition 3), which is the most prevelant version of JavaScript. The book won't be covering some of the new ECMAScript 5 features, but Cody hints that another book might be coming out the in the future to cover some of these new features that are making themselves into current browsers.

What to Expect in the book?

It is Cody's style to have lots of code examples in his book. The great thing about this is that he provides a jsFiddle link to the code so that you can pull it up in your browser and play around with it until the concept sinks in. I really enjoyed this in his last book (jQuery Enlightenment) and I'm also loving it in this book.

Cody even goes to explain that the words in the book describing the code should be secondary to the code itself. The examples are there to help you understand what is going on, which is great!

High Level Overview of Contents? 

Cody's book has 15 main chapters and each of them are broken up into much smaller pieces, but to spare you the who table of contents I've just listed out the top level chapters for you to look over below...

Chapter 01 - JavaScript Object
Chapter 02 - Working with Objects and Properties
Chapter 03 - Object()
Chapter 04 - Function()
Chapter 05 - The Head/Global Object
Chapter 06 - The this Keyword
Chapter 07 - Scope & Closures
Chapter 08 - Prototype Property
Chapter 09 - Array()
Chapter 10 - String()
Chapter 11 - Number()
Chapter 12 - Boolean
Chapter 13 - Null
Chapter 14 - Undefined
Chapter 15 - Math Function

You can actually preview all of Chapter 6 - The this Keyword on the Nettuts website if you are curious as to what some of the content looks like in the book.

Should I Get this Book?

There is a lot of great material in this book. Most of book is coding examples which means that you can get through it fairly quickly. The book is able to fit in a ton of information in less than 150 pages! I highly recommend this book. There is a lot of value jam packed in this book for a price tag of $15.

Monday, July 25, 2011

Getting Started with the AmplifyJS NuGet Package in Visual Studio

Last week I packaged appendTo's AmplifyJS Library and published it to the central NuGet server for use in your Visual Studio projects.

The package contains...
  • An unminifed version of AmplifyJS for development use
  • A minified version of AmplifyJS for production use
  • A VSDOC version of AmplifyJS that enables intellisense support within Visual Studio

What is AmplifyJS?

In case you aren't familiar with what AmplifyJS is, here is an excerpt from the website...
AmplifyJS is a set of components designed to solve common web application problems with a simplistic API. AmplifyJS solves the following problems:

  • Ajax Request Management
    • amplify.request provides a clean and elegant request abstraction for all types of data, even allowing for transformation prior to consumption.


In order to install the NuGet package in your Visual Studio project all you need to do is type the following command into the "Package Manager Console"

Once you type the above command into the "Package Manager Console" then all of the appropriate files will be downloaded to your project to support AmplifyJS.

If the command line isn't your thing and you prefer a Graphical User Interface, then you can install AmplifyJS as well by searching for "AmplifyJS" in the "Add Library Package Reference" dialog.

Referencing and Using AmplifyJS

Now that you've installed AmplifyJS all that is left is to reference the script file that was added to your Scripts folder and start using it. It is considered best practice to add your scripts to the bottom of your webpage for best overall performance. Once you do this you can start using the library right away as shown in the following code snippet.

The code that I am showing the above screenshot is a very simple example of what can be accomplished with AmplifyJS. Look at the following code and see how the 3 components work together (Publish/Subscript, Request, and Store).

You can play around with the above code inside the following jsFiddle. Click the "+" sign to launch a full editor so you can tweak with the code yourself. Try commenting out the 2nd definition of the mocked "getTweets" request. You should see real data from Twitter being returned instead of mock data.

If are interested to see how AmplifyJS might help your application then you might check out an article entitled Extending Your jQuery Application with AmpilfyJS that is hosted on Microsof't's Script Junkie website.

There is so much more you can do with the AmplifyJS library. Feel free to check out the official AmplifyJS Documentation and if you need support or more information check out the AmplifyJS Community page.

Wednesday, July 20, 2011

JavaScript & jQuery on Yet Another Podcast

Recently Jessie Liberty, Senior Developer-Community Evangelist for Microsoft, asked to interview me on his Yet Another Podcast podcast. I was honored to be a guest on his 41st show. It was very easy and enjoyable to talk with Jesse and discuss some of the things I've been excited about.

You can listen to the podcast by downloading the mp3 or subscribing via iTunes or Zune.

Some of the things that Jesse and I talked about were...

As it turns out both Jesse Liberty and I will both be speaking at the devLINK conference coming up in Tennessee ( August 17-19 ). If you are able to make it to the conference, then we'd love to meet you. 

Tuesday, July 19, 2011

filterByData jQuery Plugin: Select by HTML5 Data Attr Value

I've been using HTML5 data attributes more and more lately and have been finding it slightly awkward when I need to select element based on their data.

I find myself writing the following code snippet more than once and I just doesn't feel right to me.

I initially tweeting about my thoughts on this syntax and mentioned that I wished a better API existed. Instead of wishing, I figured the best route would be to figure something out on my own.

I ended up writing a jQuery plugin and then after talking with Doug Neiner (a jQuery team member) it morphed into the following plugin...

I want to thank Paul Giberson for recommending to use the ternary operator which has the same behavior, but minifies to a much smaller output.

I wrote some unit tests for the plugin and you can view them here...

I also wanted to give a shout out to Dan Heberden (another jQuery team member) who saw my tweet and wrote a similar plugin to solve the same issue. Dan took a slightly different approach and performs a find and filter at the same time, where as my plugin only filters the initial selection.

Monday, July 18, 2011

Google+ Invite Form

If you don't already have a Google+ account I would be happy to invite you. I've been finding Google+ to be much more conversational than Twitter as of recent.

I made the initial mistake by of letting people reply to me on Twitter for Google+ invites, but that turned into flood of unmanageable tweets and actually made the invitation process very time consuming and manual.

I eventually got smart and created a Google Form (see below) to help manage the information necessary for the invitation process. Since I have created macros to do most of the work for me, the overhead is considerably small.

What do you have to do to get on?

  • Do you have to tweet? No
  • Do you have to follow me on twitter? No
  • Do you have to add a comment to this blog? No

All you have to do is fill out the following form and I'll invite people in groups throughout the day.

I ask for a twitter handle so that I can tweet you after I invite you. It isn't necessary, but if you provide it I'll send you a public tweet saying I've sent your invitation out.

I look forward to seeing you on Google+ in the near future if you aren't already!

As far as I know in order to get on Google+ your email address needs to be tied to a Google Profile. Please provide that below.