jQuery vs. Prototype
Got a sample article from NFJS that looked at the two libraries. Thought everyone might enjoy having a look at it. I thought it was pretty good if a little long winded. DETAILS only FTW!
Ajax Library Smackdown: Prototype vs jQuery by Nathaniel Schutta
Print This Post
Web Developer Training: Compression
I may be jumping the gun here, but I thought I'd post the training a day early. Yes that's right, I have another training session that may be of interest. This one has to do with gzip/deflate and various js compression engines (JSMin, PACKER, and YUI). I may have thrown some other things in there, but I wrote most of this last week, so I can't really remember
.
Let me know if there are bugs to be fixed, or if you have anything you'd like to add.
Web Developer Training: Compression
Print This Post
Aptana: an IDE for JS/AJAX developers
One of the things that I really like when I develop is a good IDE. Now I don't usually use all the extra bells and whistles but I like auto-complete, error checking, and a solid testing engine/server.
When I first jumped on the java train, I used a community version of SunOne Studio. It was nice, it only crashed when you didn't want it too, and was the right price (for educational purposes). Later when I took more java classes I used JBuilder, for a about a week. I'm not saying JBuilder is bad, it's just not as free as Eclipse (my current favorite IDE for all my java needs).
Anyway to shorten the story, I use eclipse (or a variant like EasyEclipse) for my java and php development, but I had not found an IDE that supported prototype and jQuery (and by support I mean the previously mentioned features, you know, auto-complete, error checking, etc). That all changed when I somehow stumbled onto aptana studio.
Aptana is a fantastic IDE that is based on Eclipse, but features a built-in rendering engine/server, support for all the popular javascript libs (prototype, jQuery, mooTools, mochikit, Dojo...) and is brimming with scripts, snippets, and helper libraries. They have even developed an interesting technology called "jaxer" (which stands for ajax-server). I haven't played with Jaxer yet, but it sounds like it can do some fascinating things. There are also plug-ins for iPhone development, AIR support, and PHP development.
What I mostly use Aptana for is testing new web 2.0 pages. For example, on one of our sites we redesigned the press release page. Development on that site is done in WebSphere 5.6.1, which means I have to dig out a VM and do my work in there... which is lag-tastic (especially the test server). With Aptana, I can test everything cleanly up front and see what I'm going to get (with a quick page mock-up) before I attempt to code the whole thing in the VM. If you're bored, give it a try, it's a fairly hefty download, but it's worth playing with it.
Aptana comes in two flavors, Community and Pro. There is a comparison chart on the aptana studio download page.
Print This Post
JS Compressors
So Jason found that one of the compressed versions of prototype we were using was causing some function to not work. The prototype file in question had been shrinked using ShrinkSafe, which is based on Rhino, and is actually made by dojo (I figured since IBM has a dark-alliance with dojo, it'd work fairly well with Websphere. Needless to say, ShrinkSafe is well... crap. So here is what you should use instead.
- jsmin*
- /packer/
- YUICompressor*
*Now I didn't link to the jsmin or to YUI because they could be updated, and they are files you run locally on your box while /packer/ is a copy-paste web-util.
In my opinion YUI is the best, you can choose several different compression levels and it works very well compressing prototype, so well in fact that we got it to shrink down an extra 10k than what had been done with ShrinkSafe. Also the YUICompressor is semi-intelligent with whitespace, it checks for ascii characters before and after a piece of whitespace to know if it should remove it.
Print This Post
Form input=”checkbox” clearing
So it turns out that there is a fairly-easy way, and a wicked-easy way to handle almost things you come across. And if it feels like it's way to hard, I'm pretty sure it is. Needless to say we were on the NordicTrack site working on a form for the 'compare' feature, and we needed to clear all the check-boxes on the page whenever certain buttons are pressed (the 'bug' so that it would compare the two items listed in the series). We finally ended up with this nice little loop (lifted partially from a google code site)
var frm = document.selectionform;
var el = frm.elements
for(i=0;i<el.length;i++){
if(el[i].type == "checkbox"){
el[i].checked = false;
}
}
Now while this is super-great, I knew that it could be better done since we are incorporating Prototype into the project, but I couldn't remember the command that would make this better. Well, I just stumbled on to it. What we needed was a one liner.
Form.reset(formname)
That's it, that would have fixed the entire thing, no looping, no extra variables, just that line. Now if you use this in your own code elsewhere, remember that it erases everything from your form, not just check-boxes.
Print This Post