One method that I've been wanting for quite a while now was a simple way to format old JavaScript dates in a "pretty" way. For example "2008-01-28T20:24:17Z" becomes "2 hours ago". Here's some more examples:
Note that I only care about dates in the past (by far the most common use case) and only dates within the past month (anything beyond a month becomes fuzzy and impractical).
JavaScript Pretty Date
pretty.js (Also include a .prettyDate() jQuery plugin, for convenience.)
Demo (Some examples of date conversion using basic DOM manipulation.)
Example Usage
In the following examples I make all the anchors on the site, that have a title with a date in it, have a pretty date as their inner text. Additionally, I continue to update the links every 5 seconds after the page has loaded.
With plain DOM:
function prettyLinks(){ var links = document.getElementsByTagName("a"); for(var i = 0; i < links.length; i++ ) if( links[i].title){ var date = prettyDate(links[i].title); if( date )
links[i].innerHTML = date; } }
prettyLinks();
setInterval(prettyLinks, 5000);
There's a variety of these functions around, in various languages, but I wanted one in JavaScript for a couple reasons:
Microformats - Microformats specify a scheme for passing ISO dates to the client (precise date/time value) while providing the user with a "casual" date representation. I wanted to be able to generate a pretty version of the date, from a Microformat, easily and painlessly.
Auto-update - Secondly, I wanted to have these Microformat dates update automatically, as the page remained loaded. This way, if a user left a page open for 15 minutes, and came back, the pretty dates would be silently updated to their current times. This may seem nitpick-y but Twitter fails to do this and it drives me absolutely insane.
Write once, use everywhere - If I wanted to have these dates be constantly updated I would have these options: Only generate these dates on the server - re-querying new results via an Ajax request, generate the results on the server and on the client, or generate the results exclusively on the client. Client makes the most sense as it would result in the least amount of code duplication and general overhead.
I hope this will be useful to some, I know it's helped me out a bunch.
By the way - let's say this piece of code was from a - theoretical - larger project that was attempting to create an easy-to-use, Open Source, Twitter clone - would anyone be interested in using it?
While I'm not, currently, looking for any extra work (a full-time job and writing a book will slow you down a bit) I'm frequently forwarded job openings that I would like to pass on to others.
Generally speaking, these jobs fall into a couple areas: 1) Are JavaScript-related (either jQuery or general Ajax). 2) Are within the New York/New England area or are remote contract jobs. If you have a job posting that you'd like me to relay, feel free to contact me and I'll try to push it on.
jQuery Contract Position
Dave Merwin (dmerwin at orcasinc.com) says that he needs some help with "a small but cool project that I want to do in jQuery." Contact him if you're interested.
Boston Interface Design - JavaScript, jQuery, Python
Mark Soper (mark at alluviallabs.com) says:
Alluvial Labs is building Alluvio, a web application for collaborative investment research. The main need is for someone who knows how to make a professional and usable interface aesthetic. We also have lots of opportunity for the work to evolve into development: javascript/jquery, python, etc.
jQuery Plugin Development
Ryan Graf (ryanjgraf at gmail.com) says that:
I'm looking for an experienced developer with jQuery that can help with some work on a plugin (edit-in-place stuff). We've been working on an existing plugin provided by another contributor and have basically re-written the entire plugin to add a lot of extra functionality. We're now facing some interesting cross browser issues with IE6/Safari that have been difficult to debug.
JavaScript/Ajax Writer
Scott Delap (scott at clientjava.com) says:
InfoQ.com (which I'm the lead RIA/JavaScript editor of) is looking for a couple news writers to cover JavaScript and Ajax (for things like say ... JQuery). We'd want them to cover JavaScript and Ajax in general of course in a not too biased manner. Time commitment starts at around 1 post (30/45 minutes a week) and is paying at a competitive rate per post. Here are a few examples of the types of coverage we shoot for: 1, 2, 3, 4, 5, 6.
NYC - Senior JavaScript Engineer
Brian Vinay (brian.vinay at talentbridge.net) is looking to fill a position with Heavy.com. He provides more details:
Heavy’s engineers develop the next-generation technologies for discovering, delivering, and monetizing premium video for millions of consumers. We’re looking for outstanding front-end engineers who want to define the next generation of user interfaces for internet-based video and advertising.
We are hiring senior JavaScript / HTML / CSS software engineers to write cross-browser code for these web applications, for both internal and external use. We are looking for well-rounded developers who know how to create beautiful, lightning-fast interfaces that work at Internet scale… but who can also develop prototypes quickly. You should have a good understanding of, and practical experience with, creative web design using open standards.
Requirements:
* BS/MS/PhD in Computer Science or equivalent.
* Strong JavaScript skills and object oriented design experience, including working knowledge of jQuery, Prototype, Scriptaculous
* Good artistic taste. You will be relentless about elegant CSS layout, tight JavaScript code, all with strict and clean HTML
* Significant experience implementing user interfaces for consumer web services
* Experience with PHP, MySQL and ActionScript is a plus
* Knowledge of user interface design, XML web services and agile development methodologies desired.
* Ideally, you truly love what you do and have a web site to showcase your favorite work.
Ajax Freelance
Brandon Mullins (brandon at bookmesh.com) is looking for someone to help finish the Ajax of Book Mesh:
All of our AJAX images are designed, and the site is 95% completed. However, we are in need of locating a very talented and responsible AJAX pro to work as a direct consultant and freelancer to the BookMesh team, to begin with immediately fixing the kinks in our AJAX functionality (doesn’t work in IE at all, needs to be centered and tidied-up in Firefox & Safari). This same person will be able to stay on board as a freelancer after this small initial task for any and all client-side scripts that we will need, including various Javascript-based feature implementations.
These initial AJAX needs will not take much time at all (~ 7-10 hours), and there may be lots more work in the coming future for the selected freelancer.
Matthew Greenhouse (mgreenhouse at colspace.com) is looking for "any developers that are familiar with jquery and looking for work, ideally in NYC."
Portsmouth, NH - Web Designer
Jeff Leombruno (leombruno at gmail.com) is looking for:
...a high end developer/scripter type person. If you know anyone who might fit that role and would be interested in working in Portsmouth, NH, please feel free to pass along my email address. We're looking for someone with experience who can jump right into developing complex UI's using xhtml/css/js or flash/actionscript/flex type technologies. We do use jQuery here, of course, as well as YUI for some of our more complex interfaces.
Los Angeles - Senior UI Developer
Danny Archambault (darchambault at concorde-inc.com) is looking to fill a senior UI developer position:
Skills: Ajax CSS Photoshop JSP HTML sony Job description: UI Developer / Specialist: A minimum of 5 years of experience working in a team on a complex-phased new technology medium sized web projects. Responsible for developing the user interface for a complex web application with a lot of data entry screens, workflows, views and reports.
Deliverables will include:
* Low-tech mockups using Photoshop, Illustrator, Excel or Visio
* HTML Prototypes with functioning Javascript and data interactions
* Flex application development to support the back-end development
We have an opening in Seattle at Zillow.com for a User Experience Developer, eg. JavaScript + HTML template ownership, that we've been looking to fill for over 6 months with no luck. We've interviewed dozens of candidates, but we can't seem to find people in Seattle who have a JavaScript focus. Considering your large fan base, it would be great if you could put a word in for us, as this would be a golden opportunity for the right kind of person - that is, someone who can play a browser like a violin. While we use YUI here, I have great admiration for the principles of jQuery and would love it if we could find someone with a jQuery background. We've got some large, fun, JavaScript-intensive projects coming up over the next year+, now if only we could find a JS fanatic to build them!
NYC - Senior-level Web Developer
Mauvis Ledford (mauvis atkickapps.com) wrote to mention a job at KickApps:
KickApps the premiere white-label social networking company is looking for a Senior-level Web Developer with a core interest in JavaScript / CSS / HTML. We use jQuery here. Must be able to work or relocate to our Manhattan office. Great pay, generous benefits. See our website for more information.
Let me know if this post is, at all, useful to those reading it. If it's not the case then I probably won't attempt it again, but it is nice to pass these on, at least (especially to those looking or some extra JavaScript or jQuery work).
One problem that we've encountered with jQuery, and that I did not foresee by any stretch, was the difficulty in synchronizing releases with other projects and companies. Specifically, when certain projects need the latest copies of your code by a certain time in order to make it for inclusion.
There's two classes of problems, as far as I'm concerned:
When a project is including a library for the benefit of its users (plugin authors, module developers, theme writers, etc.). Generally these deadlines are much more important. Having a release come out in time, to synchronize, could influence the next year of development in the project. Missing the deadline causes users to be stuck with old code and deprecated APIs.
When a site needs a copy of the library in order to meet an upcoming deadline. These can be easier to meet. Typically the issue here is a single, problematic, bug fix - or important API addition. Thankfully, it's usually sufficient enough to just build a nightly for them, to get them started - it's not always a requirement that they be using the final version of a release.
Broken down within those two categories there's a degree of freedom: A site, or project, could be Free Software (and open source) or closed - and generally proprietary. How you choose to deal with each of those categories is completely up to you. For example, as an open source project yourself do you give more leverage to other open source projects in the hopes of future collaboration? or do you give more attention to corporate projects in the hopes of more eyeballs and potential donations?
At the jQuery project I've generally split our time indiscriminately but with a sleight bias towards Free Software. By biasing towards Free Software projects we're able to get better mind share amongst developers - who are our key users. For example, getting jQuery support in Drupal was a major victory for us as it meant that all future Drupal module developers would be compelled to, at least, examine jQuery to see if it suits them well, or not. While there isn't, necessarily, a financial reward to working closely with Free Software the eventual market control will be quite significant and useful for further leverage.
The actual synchronization process, itself, can be quite challenging. Frequently, only corporations tend to have rigid release schedules (which can be a good thing, as it gives you a tangible goal to work against). Whereas open source projects will have loose deadlines like "sometime within the next two weeks," which are especially problematic. The only solution here is to become really good at communication. I wish I could say that I had some magical tool that made it easy, but that's definitely not the case - and it's only barely gotten easier with time.
The result of this whole process is that you end up having to keep really close tabs on your big-name users. This is why I constructed the jQuery Evangelism team. They work hard to ping our most influential users to make sure that we keep on top making them happy. Sometimes this means some level of tech support, bug triage, and even free consulting - but the end result is most-definitely worth it.
I want to take a look at some of the best partners that we've had for the jQuery project, in terms of pay-off, from the work that we've put towards on synchronizing our releases.
Drupal - Partnering with Drupal has been huge for us. They use jQuery all throughout their system and recommend it to all of their module and theme authors as the JavaScript authoring interface of choice. They were our first partner and we've learned a lot from working with them. It's because of them that jQuery is dual-licensed under the MIT and GPL (they are a GPL-only shop). Because we were able to bend to help them we saw a huge increase in our user base. We're in the process, right now, of synchronizing for their upcoming Drupal 6 release (and will be doing an extra jQuery 1.2.3 release for them, to help them out).
Wordpress - This has been a, relatively, new partnership for us but we're already starting to see some of the benefits. Wordpress' use of jQuery was gradual. At first they included it as an optional include for theme authors, then they migrated the admin interface to use jQuery, and then finally made jQuery the library of choice for plugin and theme developers. We haven't done much, explicit, synchronization with them, yet, but this is definitely something that we should work on.
BBC - They recently redesigned their homepage to use jQuery and Interface. Unfortunately, we found out them too late and we weren't able to help them (they had been having troubles with jQuery UI and were forced to revert to using the Interface plugin). This is a case where synchronization would've helped but will need serious improvement in the future.
Digg - They've been our most loyal, and dedicated, corporate partner. We've worked hard to resolve weird bugs, included specific features, and push new releases out to help their projects. In return they've redesigned the Digg homepage to use jQuery and use it in the Digg iPhone application. We have a great line of communication here, which has been excellent.
Google - Projects at Google, using jQuery, have started to pop up which has been really exciting for us. Coordination with them has been much more challenging as it's generally on a team-by-team basis (most decisions as to which libraries should be used are done by the developers themselves rather than by the corporation). However we've had a lot of success in communicating with them on the jQuery developer mailing list and have received numerous bugs and patches, which has been quite helpful.
Adobe - This is one of our upcoming partners. We've been working with them to try and make sure that some of their upcoming releases go smoothly. This is a case where a corporation will be providing copies of jQuery for developers to use (a different use case for us, as this is typically coming from open source projects). We'll be seeing a lot more from this partnership in the upcoming months, which will be exciting. They've been great about keeping communication open - conference calls, emails, and patches - a great partner.
Mozilla - This is probably our highest communication-level partner, for the simple fact that I work at Mozilla (which tends to get developers excited, when they know that they have someone whom they can ask questions of). Additionally, however, our relationship has gone well beyond that - including the integration of our test suite into Mozilla's test suite. I've also worked hard to make sure that the release of Firefox 3 would go as smoothly as possible with jQuery. Obviously this is one of our most fruitful partnerships - playing on both teams will have that effect.
In the end, the synchronization of releases is an interesting problem. It's, generally, un-related to the actual code of an open source project but instead completely hooked to its process. I feel like a lot of projects leave administration and process by the wayside, and for that tend to suffer in the long run. It's a lot of hard work but the benefit that you'll receive, through your successful partnerships, is just too strong to ignore.
Today is the 2 year anniversary of the release of jQuery (celebrated with the release of the excellent jQuery 1.2.2).
I remember doing the first release at BarCamp NYC (combined with the mention of two other projects of mine that fizzled: Feed Pile and Idea Shrub). While I had released a bunch of open source code in the past, this was the first one that I put some serious effort into getting publicity. Luckily it made it onto del.icio.us/popular, digg - and the rest is history.
Amusingly, the entire chain of popularity was due to the fact that I made a troll-y comment on a Prototype blog post (when they announced their new selector feature) and it was discovered and re-blogged by Ben Nolan (creator of the Behaviour library for Prototype). From there it hit the Rails community and was launched onto del.icio.us, digg, etc.
It's been fantastic watching it grow and mature over time - and really see the JavaScript community come alive during these past couple years. I'm happy with what we've achieved and I'm excited, looking forward, to our prospects. Here's to 2008!
Update: Olmo and I have been in contact recently, off public-facing sites, but here's a public response that he made, and here's a private one that I gave to him:
Thank you for doing this. I want to, personally, apologize for
everything that I did during the past couple days. It was out of line
- both for myself and in general. I should've done a much-more even
tempered response, I got caught up, it turned into a flame - ugh,
sorry again.
I fully accept your apology and will be adding your comment and
modifying my post to give people more details and apologizing
publicly.
In fact, not only do we steal code, but we're incompetent at it too! Durrrr, let's swap some variables and pray it works! How does animation work? Who knows! It's one of the mysteries of the Intertubes! I mean, it's obvious that we never could've completely rewritten a popular animation library back in 2005 because we just "tweaked some variables" and prayed everyday that it would work.
jQuery hates developers, love companies
We love that sweet, sweet, money that corporations send our way. Forget developers. As far as we're concerned, they can stay in the ditch that we threw them in to drive on the way to moneytown.
File size is the only thing jQuery considers when adding a feature
It doesn't matter how useful it is, or what performance benefits we get. It's file size, over everything else. Carefully balancing facts and weighing advantages is ludicrous and highly overrated.
File size is irrelevant
Making code modular makes file size irrelevant, since you can just pick and choose what you want to use. Nevermind that the sum of the parts is larger, all that matters is that you write code for developers. Developers who don't care about file size.
jQuery code isn't modular
I mean, I think the code base would have to be broken into, at MINIMUM, over 250 modules before we even talked.
Ternary Operators!
Seriously, need I say more? Obviously the mark of incompetence.
My head, literally, just exploded. I'm dead, lying on the floor. Can someone please put "he had a lot of problems because of the closures" on my tombstone? Thanks! (I wish I was making this up, 16:20, check it out.)
Olmo: You seem immensely proud of your ignorance concerning other libraries but love to speak on authority concerning them. Maybe you should take some time to sit down and actually try to use and work with other libraries, because while you were out bashing and slandering us we were writing rock solid code, sharing, collaborating, and discussing the future of the web.
Let us know when you're ready to see the Open Web succeed, we'll be here, getting things done.
I gave a talk, recently, at @Media Ajax on jQuery (and a similar one at the Ajax Experience in Boston). I covered a broad amount of information (all the way from the absolute basics up to building and using plugins).
Three major releases, and one minor release, in less than a month will do that to you. If anyone has tried to email me and hasn't gotten a response, you now know why. Please ping me again if I haven't responded yet, I'm still working my way through the deluge.
I think this is the most non-stop programming that I've ever done, I plan on taking a short break to try and re-gain my bearings. I've got a couple un-loved side projects that I've been wanting to tinker with and release, so maybe I'll get those out the door - and possibly do some more writing.
Also, in early October I'm going to be giving some talks at the Future of Web Apps conference in London. Specifically, on the Mozilla Platform and on Client-Side User Interfaces. It looks like there's going to be a lot of fun people in attendance - I hope to see you there!