Recent Code News

|

I want to clear up a common misconception. It’s my belief that developers mistakenly call JavaScript Object literals “JSON Objects” because their syntax is identical to what is described in the JSON specification, but what the specification fails to mention explicitly is that since JSON is a “data-interchange language,” it’s only actually JSON when it’s used in a string context.


|

When I initially started releasing jQuery plugins, I asked a number of my peers how I should license them. I was already using a Creative Commons license for my photography and text, but I had read that it wasn’t recommended for software. The most common suggestion was to use the MIT license, which I really liked because it is concise, establishes that I own the copyright, that the software in question is free, and that no warranty is provided.

You might not be thinking about this now, but it’s never a bad idea to state somewhere that this hard work, that you’re doing free of charge because you love open source, is provided as-is, without any kind of warranty. I’m not saying that anyone is going to hold you liable and take you to court because your code broke in production due to some wacky bug, costing them thousands of dollars.. but you’re better safe than sorry, right?

Either way, the MIT license allows people to pretty much use your code however they want, in a free or commercial product, as long as they keep your copyright notice intact.

So, that’s it, right? Well, that’s actually only half the story…


|

I never really expected to categorize a post as both “code” and “music,” but you know those “there’s an app for that” iPhone commercials? Well, apparently, “there’s a Ben Alman jQuery plugin for that.”

After I had gone to sleep last night, Jonathan Neal, author of the jQuery SWFObject plugin, jQuery sIFR plugin, CMS.txt and the creator of the yayQuery podcast theme song posted a new track into IRC…


|

Recently, Elijah Manor and Ralph Whitbeck asked me if I’d like to be a guest on the Official jQuery Podcast. Of course, I agreed.. and last week, Episode 6 was recorded.

First, let me just say that it was a lot of fun! We had a lot of laughs, and not all at Elijah’s expense (but mostly), and actually talked about some useful, jQuery-related stuff.

We talked about plugin development, code organization and one of my contributions to jQuery 1.4 core. We also discussed some general suggestions for developers who want to contribute to the jQuery project, but aren’t sure how to get involved, and I gave a rundown on a handful of my plugins, what they’re called, what they do, etc.

In addition to the actual “useful” stuff, we heard a few of my tunes, I explained where the nickname “Cowboy” came from, and oh yeah, we talked about the hottest new John Resig-related internet meme!

If you haven’t heard The Official jQuery Podcast, Episode 6 yet, what are you waiting for? Check it out now on the jQuery Blog, and let me know what you think!


|

Recently, Cody Lindley asked me to take a look at his new book, jQuery Enlightenment, and write up my thoughts. Now, I’ve never written a book review before, but since I’ve spent a lot of time helping novice jQuery users understand programming and design concepts as they relate to both jQuery and JavaScript, I saw this as a good opportunity for me to weigh in on a book written for exactly those people.


|

If you’ve tried out jQuery 1.4a2, you might have noticed that, among other things, the $.param method has seen some significant improvements.

I’d like to take a few moments to explain how request params parsing works, and how things have changed in jQuery 1.4.


|

I recently encountered an odd behavior in WebKit while testing jQuery BBQ on a page that lived in an Iframe. What I initially thought might be a bug in jQuery BBQ actually appears to be a bug in Webkit, so I set up an example page that shows how location.hash browser history breaks in an Iframe, in WebKit, Safari, and Chrome.


|

Recently, Katherine Senzee at Acquia contacted me to ask if I would consider dual-licensing my jQuery BBQ plugin as both MIT and GPL, because they wanted to include it in the upcoming Drupal 7 admin interface.

The idea is for the admin interface to appear as a modal window on top of the current page, with fully function back/forward button functionality, while maintaining the context of the current page. This is, of course, a great idea.. and one that jQuery BBQ makes easy!


|

A while back, I coded up a very basic nextUntil method, but it felt a bit simplistic. I felt that I could code a slightly more “general” solution that actually sorted correctly.. so here’s the result:

jQuery Untils provides three very simple, but very useful methods: nextUntil, prevUntil, and parentsUntil. These methods are based on their nextAll, prevAll, and parents counterparts, except that they allow you to stop when a certain selector is reached. Elements are returned in “traversal order”.

Note that these methods take a less naïve approach than others bearing the same names, and are designed to actually return elements in traversal order, despite the element ordering flaws inherent in the jQuery 1.3.2 selector engine. A ticket and patch have been submitted to the jQuery team for hopeful inclusion in the 1.4 release.

Check out the documentation and examples at the plugin page, and let me know what you think in the comments!


|

Today, when I started BBEdit, it asked me if I wanted to update to the latest version (9.3), and after it installed, I was greeted with a lovely surprise: there is now an option to set “Invisible characters” colors in the preferences!

Apparently, Rob Griffiths posted about this on Macworld shortly after I posted it to my blog and to Mac OS X Hints, which must have given it a bit of traction. Unfortunately, I didn’t get a link back to my original post, but the end result is the same.. the feature is now officially in the app!

Thanks, Barebones, for a great product!


|

A jQuery BBQ user came across a rather interesting behavior in Firefox the other day, so I set up an example page to test things out.. and it turns out I’ve either encountered a completely useless “feature” or a legitimate (and annoying) bug in Firefox when setting location.href in a remote XMLHttpRequest callback.


|

Lately, I’ve been spending a lot of time trying to find new ways to optimize websites to enhance the front-end and the overall user experience. I’ve already spent some time working with CSS sprites (on benalman.com, for example) to reduce the number of HTTP requests, but just yesterday I decided to revisit a CSS technique I had been using for years, to see if I could optimize it somehow.


|

The title of this post pretty much says it all, so you might as well not even bother reading the rest. But if you must..

First, I’ve updated jQuery BBQ to 1.0.2, fixing a few minor IE bugs along the way. Things should now fully work in IE8’s “Compatibility Mode” and “IE7” modes, as well as in IE6/7 when used on a page with an https:// protocol. If you do notice any other bugs, please let me know.. and if you notice a bug you can fix (and test), fork BBQ on GitHub!

Also, I’ve fully moved the source of JavaScript Debug over to GitHub, so check that out.

And I’ve actually created a plugin “shell” that I will be using as the basis for all my jQuery and JavaScript projects on GitHub, which should facilitate my moving everything over there. I’ll (obviously) post more on this as I move things, so stay tuned!

Oh, and if you missed it late last week, I created the “world’s first” jQuery Star Wipe plugin, so be sure to check that out. It’s mind-blowing. Or not.


|

I’ve just posted v1.0 of my jQuery urlInternal plugin, which will allow you to easily test internal-, external-, or fragment-ness for any relative or absolute URL. The plugin includes element filtering methods and pseudo-selectors, as well as some helpful configuration methods, should you need them. Check out the project page as well as the source on GitHub.

And now that both jQuery urlInternal and jQuery BBQ are completed, the URL Utils plugin is completely obsolete. It will still continue to work, of course, but will no longer be supported or updated, because the new plugins are better! Seriously!


|

A while back, Paul Irish turned me on to gyazo, a very small, very simple, very free app that allows you to very quickly share screen captures over the web. It works by first using the operating system’s own screen capture tools to snap an image of a region you specify, then it uploads that image to gyazo.com, opening it in your web browser. The URL is even copied to the clipboard afterwards.

Perfect, right?

Well.. almost perfect. Because of firewall restrictions, I found that gyazo.com was blocked for some of my friends, so they couldn’t see my screen captures. Also, I really liked the idea of uploading the images to my own server, so that I’d have full control over them.

So, that being said, I decided to crack open gyazo.app (Right click, Show Package Contents) and see if there was anything I could do to change that.

More Recent Code News