Follow me: @D_mitar

Most read posts recently



Dec 17th 2010 × Intermoos part 5: Ryan “rpflo” Florence. On moo4q and ninjas

Here’s the next instalment in our Intermoos series: we sit and talk with Ryan Florence, one of the most extraordinary and well respected coders, the man behind moo4q, SlideShow, mooDocs and the MooTools magazine. I thought he was Italian (or at least French) for a long time. I was wrong…

Name: Ryan Florence
Nickname: rpflo
Country: USA
MooTools team: none / occasional contributor
Age: 29
Company / Occupation: Clock Four / Senior Technical Consultant
Blog: http://ryanflorence.com/
Website(s): http://moodocs.net
Twitter: @ryanflorence
GitHub: https://github.com/rpflorence
Famous for: The blog, the magazine, moo4q, SlideShow, MooDocs
A little bit about yourself and your background…
I live in Salt Lake City, UT with my wife and two kids (a 3 year-old iPad addict daughter, and a chubby 3 month old boy). I work from home for the bay area creative agency, Clock Four doing mostly front-end development.
How and when did you get involved with JavaScript and MooTools?
My first real job was back in the 90′s cranking out websites as a teenager for a local ISP. I tried to learn C++ in 21 days but couldn’t get past the second chapter. About the time Java applets started popping up on websites the ISP went broke. I had no interest in programming and started selling decals I made at school online (people actually mailed me hand-written checks!)

After college I was in sales, and eventually ended up working as an implementation consultant for PolicyTech, renewing my interest in web development. Dissatisfied with quickbooks on my Mac I decided I’d learn how to write a web application in PHP and JavaScript to handle my invoicing and accounting. I found scriptaculous first, but couldn’t get some animations to quit bumping into each other; then I found MooTools and its genius Fx module. I was still clueless though, mind you.

Shortly after this, MooTools 1.2 came out. The new documentation flipped a switch in my brain or something. Suddenly the concepts of objects and classes made sense. I rewrote my invoicing application as a single page, desktop-esque, ajax heavy, ridiculously awesome tool that I still use today. As I dug deeper into MooTools I accidentally uncovered a pot of golden, vanilla JavaScript knowledge.

Being self-taught, I put a high value on documentation. I wrote MooDocs to document and release my scripts and provide a way for others to share theirs (no forge yet). That site earned me an invitation into the MooTools developers circle and I’ve held the “MooTools FTW” banner ever since.
You seem to have an apprehension of MooTools that is very hard to beat and champion it daily. Why MooTools though, was it love at first sight or did you jump over from another framework?
Oddly enough, MooTools was my first programming “language”. It was my programming university–it taught me to focus on the API, test my code, and program patterns rather than implementations. Now I view everything else with that bias, whether it’s jQuery, Ruby, or Objective-C.

I stick with MooTools for two reasons. First, I love JavaScript. The Type extensions allow me to write clean, natural JavaScript–no screwing around with namespaces and abstractions that hide the language: arr.include(item) versus ns.utils.array.include(arr, item). Second, I love classical inheritance, and object templates. My brain is naturally wired to think that way. The world around me is designed that way–dogs inherit from mammals. The end goal is to reuse code, which I can’t seem to do as well with differential inheritance–which is like, Siamese twins can share the same legs, right?
I know you’re also a bit of a jQuery user (cough) and in trying to make it more usable and scalable, you created moo4 – a project that brings MooTools Class to jQuery. How is that going and do you think it can ever be considered stable and reliable enough to be used as the basis of serious Web App development under jQuery?
Moo4q definitely elevated my reputation in the JavaScript community and was a lot of fun to figure out. It’s certainly stable, I’ve used it several times in production (it’s just a custom build of MooTools plus a small Class mutator). The site gets about 100 visits a day, mostly to the tutorial page, so I think there are a few folks actually using it.

As for using it in a serious application, I dunno. From a MooTool’s perspective you’re really just swapping out the Element, Fx and Request modules for jQuery–which doesn’t really offer you anything new or better than what MooTools already has. From a jQuery perspective, you have to learn so much about MooTools’ patterns, you might as well jump all the way in.

So you’re probably asking why it exists. I use it in two cases. 1) I’m stuck with jQuery and need to do something that I’ve already done in MooTools. I’ve found that usually 10% or less of my classes have to be adjusted to become moo4q classes. 2) I’m delivering templates to a client who only knows jQuery. I can still structure my stuff the way I like to, and they can do whatever they want with jQuery after delivery.
Do you think that having something like moo4q “out there” may dissuade users from swapping over to MooTools for more involved app building? It’s as if you have just taken away one of its biggest advantages and brought light to the blind (I am only half-joking, heh)…
Haha, yeah. Originally I had hopes of it being a gateway drug for jQuery users to eventually fully convert. But in the end, moo4q is mostly appealing as moo4-devs-stuck-with-q. I don’t think it hurts MooTools adoption, probably helps by showing outsiders quite plainly what it can do. It also serves as a solid demonstration of the scope difference between the two.
What are you working on at the moment (on the framework itself or related)?
Man, I think I have development ADD. Outside of outlining more articles for my site, I’ve been working on a lot of stuff. SlideShow 2.0 is a few commits away, which brings with it a handful of (awesome) improvements and performance gains, including CSS transitions.


Speaking of which, I just released CSSAnimation, a vanilla JavaScript implementation of CSS transforms and transitions–complete with MooTools and jQuery API extensions. It powers the new transitions in SlideShow.

Two new scripts I’ve been giving a lot of attention to are Channels and Element.Behaviors. Channels is an extended pub-sub pattern that allows you to completely decouple your objects from each other. Element.Behaviors lets you separate your JavaScript from the DOM. The two together have been a lot of fun to work with.


On the SSJS front, CrypticSwarm and I just started porting packager to packager-node. I’ve also recently written an alternative MooTools documentation browser as my first node project that I hope to make a whole lot better now that I’m learning more.
Are there any other Open Source technologies or projects you are involved with?
My website is built with nanoc, a static site generator built with Ruby. It’s surprisingly powerful, and has sped up my development process at work for building micro-sites and similar projects. Haven’t had the time to give back to the project, but I have some stuff I’d like to contribute.
If time and resources were not an issue, what new features or changes would you like to see most come into the framework or the website?
Core – MooTools Core has had the same API for 2 years (!), it was done right. But I’d love an ES5 shim with no dependencies and more modularity with the Type extensions. There’s a lot of those extensions in Core that are rarely used (string.hyphenate?). At least $chk is gone, which was useful for allowing 0.

UI – I’d love to have a UI library comparable to Dojo dijit.

Website – I think a node version of the forge will get a lot more interest and contributions from the community and packager support would be awesome. Also, I’ve been promising Darren my time to write a whole boat load demos to help the sorry demos page out.
If you had not been involved in MooTools, what do you think you’d be doing instead?
I’d still be flying around the country consulting people on how to manage their policies and procedures, making a whole lot less money. I owe just about everything about my current employment to the MooTools community. David Walsh is responsible for 50% of my twitter followers and website visitors, and is always a great sounding board for APIs I’m trying to develop for my plugins. I’ve learned almost everything I know about web development from everybody who hangs out in IRC (and Aaron Newton, who doesn’t). I owe a special thanks to Thomas Aylott, who got me my current job and has helped me understand JavaScript and web development more than he probably realizes. So yeah, without MooTools, I probably wouldn’t be a developer at all.

Dimitar: Yes, I need to get SubtleGradient to say a few words here too…
So, jQuery is the biggest framework out there but MooTools is sat prettily at the #2 spot. How do you envisage library evolution and the ‘scene’ in the future?
jQuery will remain #1. Like I said on twitter a while ago, most everything about jQuery is an implementation, making it ridiculously easy to learn. Even with the recent rebirth of JavaScript, most people making websites still don’t know, or care to know, the language. For them, jQuery is the obvious choice, and rightly so.

However, people are writing more JavaScript than ever and need more than just a DOM library. Alex Sexton has an awesome talk called jQuery’s best friends. He’s a smart, influential guy. I think his approach to pull in other tools outside of the jQuery scope is totally appropriate. We are already seeing the advanced jQuery users adopt this strategy.

On the flip side, you’ve got bright developers like Rebecca Murphey turning away from jQuery for their bigger projects. When jQuery users start feeling that “holy crap, what have I done?” feeling with their JavaScript, Dojo is the natural place to go. Just search and replace $ to dojo and you’re more than half way there. Nearly every jQuery method has a Dojo cognate. Also, both hang everything from a namespace. This makes it an easier transition than jQuery to MooTools. Add to that its incredible UI library and support and I’m quite sure Dojo will become the top library for non-trivial websites, if it isn’t already.


So what about MooTools? MooTools doesn’t seem to care a whole lot about adoption (look at our demos page), so I don’t see us making any sort of huge leap in market share. It’s a completely different paradigm. When all the books freak people out about extending the prototypes of Array and String, etc. or that “JavaScript doesn’t have classes” it adds a level of FUD that some just can’t get over. I do think, however, that our user base will continue to grow with really talented people.
This is a thorny subject but since you are a versatile programmer that can and does use multiple frameworks, how do you decide which one to include in your projects? What is your criteria/checklist?
Good question. Developers switch projects, contracts, and companies so often my motivation is mostly for the person stuck with my code a year from now, which boils down to support and documentation. MooTools is of course my default choice so I tend to ask myself these questions to justify not using it.

Who is going to maintain this code?
I write a lot of front-end templates for clients to implement into their CMS (or whatever). Once delivered, I’ll probably never see it again. Most of the time the client’s developers have little JavaScript experience outside of jQuery, so I use jQuery in these situations. If there are some really sophisticated specs, however, I’ll push the client to use MooTools, or just slip moo4q in the back door.
Do I need a UI library?
One word: dijit. It’s a part of the Dojo toolkit, well documented, and therefore likely to be supported well into the future. Everybody ought to spend an afternoon playing with Dojo dijit.

jQuery UI has a miserable API, so I’d never choose it.
MooTools doesn’t have an official UI library so you’re on your own to write and document an API, or you have to rely on plugins that may or may not have good support and documentation now or in the future. If it’s a personal project, however, MooTools, regardless.

Which browsers are supported?
Occasionally I get to work on something that only has to work in the newest browsers. In these cases I shed all the libraries and go commando with vanilla JavaScript.
What does the client dictate?
Sometimes I have to use jQuery, even if another choice would be better, because the client says so (ASP.NET, cough, shipswithit, cough). It’s not worth the fight and I like getting paid :D
If you could give one tip to new MooTools developers, what would it be? Aside from “Learn javascript”, that is?
Actually, I wouldn’t say “learn JavaScript.” When you learn MooTools, one day you’ll wake up and realize you’ve learned JavaScript.

That aside, I think my single tip would be read the source to the plugins in Core, More and the Forge (Core has some crazy JavaScript, but Fx.Tween is easy to understand). When you’re writing something that feels similar to something else, go read the source, see how they did it.
Your favourite MooTools website or plugin:
Website – jsFiddle. Plugin – SlideShow. I know it’s my own, but it is so useful for content that shares the same space (not just slideshows) I often forget that I wrote it.
Your top 5 resources for web developers (can be websites like jsFiddle, IDEs, tutorials, CSS frameworks like boilerplate, etc)
  1. Google
  2. Your editor’s documentation
  3. People, mentors, mailing lists, IRC
  4. Modernizr
  5. Early morning hacking–your mind solves the problems in your sleep, dead serious
Do you have any example sites you want to share / show off? I saw you mention the launch of new one the other day?
We just launched a new site for Capital One, advertising their student credit card, Journey. I had some extra time so I screwed around with 3D transforms and CSS transitions on the credit-101 page (safari only). It’s this project that led to Element.Behaviors and CSSAnimation.
You’ve certainly hacked a few interesting solutions recently and I am still searching for the first MooTools self-confessed ninja, is that you?
No, not me, although I did create this. All of my code is pretty much beginner’s luck, which is not the way of the ninja.

Is that your ostridge there? Thanks for your time!


Dec 14th 2010 × Intermoos series, part 3: “ketching up” with Christoph Pojer

Another day, another “intermoo”. I really wanted to get Justin Bieber to comment on MooTools today but seeing as he refused to commit to answering my questions, I got the next best thing: the chance to ketchup[1] with Christoph Pojer from the MooTools core team.

When you meet with Chris, there’s something endearing about him, and it’s not just the way he says ‘mutuulz’ (you can watch this talk on mootools Chris gave earlier this year and see what I mean). We try to find out what drives him on today.

Name: Christoph Pojer
Nickname: cpojer
Country: Austria
Occupation: Student of Software Engineering and Business Administration
Blog: http://cpojer.net/
Twitter: @cpojer
GitHub: http://github.com/cpojer
Famous for: MooTools Core Developer, PowerTools!, small height
A little bit about yourself, your background…
I am 21 years old and I live in the wonderful city of Graz in Austria. I am a student of Software Engineering and Business Administration at the Graz University of Technology. I would define myself as (Mobile) Web (Application) Developer and I am active on the Internet for as long as I have a connection – that’s about ten years now!
How and when did you get involved with MooTools?
When I started with web development I started using JavaScript. I didn’t learn the language at first but when JavaScript and XHR got more widespread adoption later in 2005 I started building my own little animation library. Shortly after I found moo.fx and I became a frequent reader of the mad4milk blog – the place where “moo.dom” and “moo.ajax” were released which eventually lead to MooTools. I was a MooTools user since the famous 0.87 version and I remember bugging Valerio to include “DOMReady” back in the days. I stuck around and got to know the core developers but only a few years later I started to actively contribute and eventually I became a member of the Core Development Team.
Why MooTools, what makes it special?
The module that got me using MooTools was Class.js. Back in the days we didn’t even have inheritance or mixins but given that I was unaware of the prototype-based nature of JavaScript, Class made me feel like home. Ever since, I love how MooTools works, the abstractions and the clean code, just great. However, at the moment, the most important part about it is our community. I actually got to know and got to meet a lot of the MooTools developers and they have all become great friends.
What are you working on at the moment (on the framework itself, related or otherwise)?
Right now I am doing lots of probability theory, object oriented analysis, data structures and algorithms, software architecture and information security related stuff. That, of course, doesn’t have anything to do with MooTools but during the semester I don’t have time for anything else really. But fear not, in the web assignments I am of course making use of MooTools (and PowerTools! ;) ). Recently I did some experiments with DeviceOrientation and DeviceMotion on iOS 4.2 (see http://twitter.com/#!/cpojer/status/7485711225716736).
Are there any other Open Source technologies or projects you are involved with?
You can usually find me doing work around the JavaScript eco-system. Therefore I am involved in a number of minor projects, nothing similar to MooTools. I am involved with GitHub. It makes the development experience so much better and more fun – it is easy to contribute to almost anything.
You have recently done some amazing work on the MooTools PowerTools! which help a fair bit in making the framework portable on all handheld devices. Do you see the role of internet phones grow and the need for proper portable javascript support to go with it? Are there plans to port some of your work into the MooTools core or more?
The goal of PowerTools! is not to make MooTools mobile compliant – MooTools works great on mobile devices already. One part of PowerTools! is the mootools-mobile project, which brings custom gestures and more for your mobile web app. PowerTools! is about providing low-level MooTools extensions or HTML5 related plugins that help you speed up the development process or to make your code more maintainable. As far as mobile is concerned, yes – mobile browsers have a lot of catching up to do, but we will get there. The mobile web is definitely important. PowerTools! is currently standalone and there are no plans to officially include it with MooTools. I don’t want to bloat our beloved library ;)
Would you share your thoughts on what the future holds in terms of HTML5, CSS3, V8, next gen browsers, server-side javascript, the role of frameworks and MooTools in web application development?
Oh well, there are a lot of buzz-words in there. I honestly have no idea, unless you have time to read five different scenarios on how the future might turn out? Haha, I thought so. Seriously speaking, it’s difficult to say. I think its reasonable to say that the amount of abstractions will increase and a lot of things will get easier even though under the hood they become much more complex. It’s just the beginning. And also, it’s just JavaScript.
If time and resources were not an issue, what new features or changes would you like to see most come into the framework or the website?
MooTools 2.0 of course! The whole thing will blow your mind, once its done of course :P
If you had not been involved in MooTools, what do you think you’d be doing instead?
Well, that would mean I would not be involved with anything related to the Web. I’d probably just go for a BA masters, but that would be the most boring thing… In any case, without MooTools my life would be very different, not nearly as awesome as it is right now and I wouldn’t have made so many great friends – I am really grateful. Also, the word “Ping!” would not make me laugh, Djamil wouldn’t be a funny person and ketchup would just be ketchup.



**editor** [1] to fully appreciate what he’s saying, you really have to see the MooTools core team eat burgers, chips and ketchup, or rather, have some food with their ketchup. Failing that, you can always login to IRC and “ping” cpojer, he loves it!

MooTools is now officially the 2nd largest framework / library out there, how do you think it will grow from here?
The numbers vary, I am not so sure about their correctness. MooTools is being used a lot behind the scenes – in huge internal applications. That is where I see MooTools. If you want to do serious web applications, MooTools is the obvious choice. Given that we are moving to a “Web of Apps”, MooTools has a good starting place. Let’s see where the journey will go.
If you could give one tip to new MooTools / javascript developers, what would it be?
What I have found is that most Web Developers still do not have an idea of what they are really doing. My advice is to learn the core concepts, learn about how the Web works, learn about object oriented languages, learn JavaScript. If you know the basics it only gets easier and a whole new world opens up every time you learn something new. MooTools can help you hide the complexity behind JavaScript and makes it easier to get started. Also, don’t be afraid to ask questions. It is what I do all the time when I want to learn something. Join the #mootools IRC channel on Freenode and ping me (cpojer), I’m happy to help!
Your favourite MooTools website:
I don’t usually have one. If you want to learn MooTools then go to David Walsh’s (FTW) website http://davidwalsh.name/ – also, the site is awesome for using the hover-effect on links which I created :) Some people claim David stole them, I refuse to believe that.
Your top 5 resources for web developers (can be websites like jsFiddle, IDEs, tutorials, CSS frameworks like boilerplate, etc)
GitHub. MooTools.net. PowerTools!. NetBeans. Chrome Web Inspector.

Thank you for your time!


Dec 12th 2010 × Intermoos series, Part 1 – David Walsh: MooTools FTW, didn’t you know.

Hello and welcome to our new series: “Intermoos“. What it is, is a series of interviews with members of the MooTools team and community that have the time to spare. We ask them a few annoying questions, we get a few interesting answers, you get the idea.

And what better way than to start it all off with a one-to-one with none other than David Walsh, the extraordinary blogger and MooTools contributor (also famous for being Arsenal’s only American supporter). Without further adieu, here is what he had to tell us…

Name: David Walsh
Nickname: davidwalsh
Country: USA
Blog: http://davidwalsh.name/
Website(s): http://scriptandstyle.com/
Twitter: @davidwalshblog
GitHub: http://github.com/darkwing
Famous for: being an awesome mootools rockstar, “mootools ftw”
A little bit about yourself, your background…
My name is David Walsh and I’m a 27 year old Web Developer living in Madison, WI. I’m a self-taught developer that is obsessed with learning everything there is to know about front-end web development. My expertise is in HTML, CSS, JavaScript, and PHP. I work with jQuery, MooTools, and Dojo on a daily basis. I don’t design the websites, I make them work.
How and when did you get involved with MooTools?
My first exposure to MooTools involved a project that required smoothly animated elements. I found jQuery and its animations where laboring to say the least. MooTools’ animations were as smooth, efficient, and the the syntax was logical. From there I was hooked. I started a blog to share my findings and experimentations. I got better MooTools and started getting noticed by the community. A few commits and dozens of blog posts later, I was asked to join the MooTools team. Joining the MooTools team is one of the proudest moments of my career.
Why MooTools, what makes it special?
MooTools is special for several reasons. The MooTools API is as coherent and logical as you will find in a framework of any language. The code is as well written as you’ll find. MooTools is modular, efficient, and provides an outstanding inheritance pattern. The MooTools team cares about its community. MooTools isn’t about marketing itself and begging for attention – MooTools is about outstanding code to create dynamic, fast websites. MooTools is magic!
What are you working on at the moment (on the framework itself or related)?
Per the framework itself, I always have two goals: making the community aware of new features and strategies, and creating useful, well-coded plugins to display the power of MooTools. I don’t spend much time on committing to the repository other than quick fixes and documentation updates – my strength is spreading the good word Moo.
Are there any other Open Source technologies or projects you are involved with?
I work for SitePen so I occasionally commit quick fixes to the Dojo Toolkit. I write exclusively about open source projects on my blog, and give my code away for free.
You have always tried to work very hard through your excellent blog on promoting MooTools and helping out new (and seasoned users). You are now pretty much _the_ most celebrated MooTools team member and community figure out there (going by readership and Twitter popularity, at the least). What drives you daily to spare the time and show such dedication?
I work so hard because I love JavaScript, MooTools, and its community. Let’s face it – we’ve all faced a technical problem that we’ve needed to scour the internet to figure out. Most people find their solution and move on. I’ve vowed not to do that – any solution to a complex problem that I find ends up on my blog so that other people don’t need to suffer the same pain that I did.

Per the MooTools project specifically, I strive so hard because I’m so passionate about the project. I love the codebase, respect the hell out of the developers creating the code, and appreciate the MooTools community. I could write a million blog posts about MooTools and not feel I’ve given as much to the project as its given me. MooTools FTW.

You have recently adopted a practice whereby you post similar snippets of code for MooTools, jQuery and Dojo, demonstrating the similarities and differences in their respective approaches. Isn’t that even more taxing and difficult to do? Does MooTools still remain as your framework of choice?
The motive behind writing code to accomplish similar tasks with each framework is to show my readers that, in the end, it’s just JavaScript. Dojo, MooTools, and jQuery are very different but in the end, they’re just an abstraction of JavaScript patterns and APIs. I also do it to show developers the different coding patterns available and the differences in syntax.

What’s important, more so than preferring one framework over another, is find the framework that best fits a project. You can love jQuery but what if it’s not a great match for a specific project? You’d be wasting time using it. In the end though, if all things are equal, I’d use MooTools before any other project. Extendible, compact, logical… those are what MooTools is all about.

Would you share your thoughts on what the future holds in terms of HTML5, CSS3, V8, next gen browsers, server-side javascript, the role of frameworks and MooTools in web application development?
The future is looking up! Let’s be honest: the reason we create (and use) CSS and JavaScript frameworks is because the tools we need aren’t available at the present time. HTML5′s markup rules bring us back to a more common-sense approach, and its new JavaScript APIs like WebSocket, classList, and storage APIs are outstanding. V8 and server-side JavaScript are also exciting – imagine writing and entire website, front and back-end, in just JavaScript! MooTools works on both the server and client side which is even more exciting! WebKit-based browsers continue to amaze me – the capabilities they provide, especially with CSS animation, are percolating. Using CSS-driven animations instead of JavaScript animation will lead to faster, smoother interfaces. I’m excited to see what’s next!
If time and resources were not an issue, what new features or changes would you like to see most come into the framework or the website?
I would like to see some of the MooTools 2.0 features incorporated ASAP, including CSS animations and the unified Fx timer. These features have been coded but not implemented so as to not create such a jump in upgrading. There are many other features in the 2.0wip branch that I would love to see implemented. Unfortunately, now is not the best time to release these features due to other API changes that would be required.
If you had not been involved in MooTools, what do you think you’d be doing instead?
I owe much of my career advancement to MooTools. MooTools ignited a fire the fire which made me dedicate my career to JavaScript and front-end development. I’d likely be working at an average Web Development shop, waiting for the clock to hit 5:00.
MooTools is now officially the 2nd largest framework / library out there, how do you think it will grow from here?
Like other web technologies, MooTools’s future is nothing but up. Our development team continues to grow, as does our loyal, intelligent community. As far as features I’d like to see, I’d love to see a Dijit (Dojo Toolkit) UI competitor created for MooTools. I’m also hopeful that the Forge continues to grow at its current pace – it’s a treasure chest of great MooTools plugins!
If you could give one tip to new MooTools / javascript developers, what would it be?
My tip would be this: when you create a plugin/class, take a step back and ask yourself:
`Can I make this class more generic so that it could be used for other purposes?`
If so, create that base class and use MooTools’s Extend/Implements methods to create your more specific class. MooTools is founded on flexibility – learn how to properly use its inheritance methods and you’ll be an unstoppable programming force.
Your favourite MooTools website:
This will sound insanely vain but I have to say my own. I refer to my own website often to grab code I’ve posted in the past. I also get user feedback so I can improve my code. I also love the MooTools Forge – its code holds the value of Fort Knox.
Your top 5 resources for web developers (can be websites like jsfiddle, IDEs, tutorials, CSS frameworks like boilerplate, etc)
A few people you should really be following if you’re into MooTools, jQuery, or just JavaScript in general:

Ryan Florence (http://ryanflorence.com/) – Ryan’s an outstanding JavaScript developer that writes interesting tutorials about jQuery, MooTools, and CSS animation. He’s the creator of MooTools SlideShow, Moo4q, and MooTools’ pub/sub plugin: Channels.

Kris Zyp (http://twitter.com/kriszyp) – Kris is a Dojo committer, author of the JSON Schema spec, and creator of Persevere, a server-side JSON technology. Kris is a JSON guru, server-side expert, and overall JavaScript nut.

You have written a plugin for everything conceivably possible, from the ever so popular ScrollSpy (no.1 plugin on the forge) to tackling heatmapping, custom pseudo selectors, history/visited spying and Twitter feed parsers. There are over 800 demos on your site with most of them being MooTools-based. Is there anything left you have not been able to write? What is your favourite plugin of all time (yours or otherwise)
There are a billion more plugins left for me to write! I’m hoping to write a Facebook photo-tagging clone soon, as well as anything else I see that tickles my fancy. Wherever there’s an idea there’s a MooTools plugin to write. There are only two limitations to MooTools plugin creation: inspiration and time. I could write MooTools plugins forever!
If you want to share some examples of your work…
I’m not big into self-promotion, but a few of my more popular posts and MooTools plugins include:

  • ScrollSpy – A MooTools plugin which monitors scrolling to fire events based on page position.
  • LightFace – A Facebook Lightbox clone which handles AJAX, IFrames, Images, and more.

If you want to see what I’m all about, visit my blog: http://davidwalsh.name

Are you a javascript / MooTools ninja and what do you think of the new ‘ninja’ culture out there?
‘Ninja’ is a lame term to try to make JavaScript development seem exciting to outsiders. In any event, the boom in JavaScript popularity is nothing but exciting. More bright minds to solve client side problems is a boost to JavaScript development and provides more ideas to the development pool. JavaScript is the future of web development.

Thank you for your time!


Aug 13th 2010 × mootools Request.JSONP to decode shortened url hashes

I tend to get annoyed about URL baiting that takes place over social networks – you really don’t know what’s behind a shortened URL until you click it. Or… until you run a URL resolver that can help. In building my Twitter Trend Aggregator, I came to explore this and found an invaluable service through the API of longurl.org that can uncrunch almost any shortened URL to its original.

Here is the extended Class (http://www.jsfiddle.net/dimitar/3Ntnr/)

Request.longURL = new Class({
    // decode a long url
    Extends: Request.JSONP,
    options: {
        log: !true,
        url: "http://api.longurl.org/v2/expand",
        data: {
            url: "",
            format: "json"
        }
    },
    initialize: function(loc, options) {
        this.parent(options);
        this.options.data.url = loc;
    },
    success: function(data, script) {
        this.parent(data, script);
    }
});
// example usage
var urls = [
    "http://bit.ly/b5Ukzp",
    "http://tinyurl.com/33wz7sv",
    "http://is.gd/e7S7R",
    "http://post.ly/r49y",
    "http://www.google.com/" // won't do anything to it.
];

var output = document.id("output");
urls.each(function(url) {
    new Request.longURL(url, {
        onSuccess: function(data) {
            new Element("a", {
                href: data["long-url"],
                text: url + " -> " + data["long-url"]
            }).inject(output);
        }
    }).send();
});

For a better example of this, visit the Twitter Trends Thingie I wrote and mouseover any encoded URL (or press the ‘Unshorten Tiny URLs’ link in the top right bar).

If you want to just deal with the good old bit.ly, then you can go to them direct like so:

// get all links on page that are bit.ly and decode them
document.getElements("a[href^=http://bit.ly]").each(function(el) {
    var url = el.get("href");
    new Request.JSONP({
        url: 'http://api.bit.ly/v3/expand',
        data: {
            shortUrl: url,
            apiKey: 'R_e744c730bdde44a7eacc88cb892074e7', // change
            login: 'webtogs2' //change this
        },
        onComplete: function(response) {
            el.set({
                href: response.data.expand[0].long_url,
                text: response.data.expand[0].long_url
            });
        }
    }).send();
});

Happy social networking


Aug 2nd 2010 × twitter trends aggregator tool

Just a quick post, really. I wrote a little pseudo twitter client that archives hash-trends and allows for post rating and filtering of spammers within different followed trends. click here to see the moootools archive.

In this early beta version, I am also archiving various e-commerce trends for the purposes of statistics on trends and twitter applications but soon it will just follow webdev ones like #javascript #seo #php #css etc. Feedback welcome.

Under the hood: Powered by PHP and mootools 1.3beta (for now), there’s a known problem in IE7 event delegation for mouseout:relay(), similar to the mouseenter workaround that needs refactoring but I have left that for another time. More to come soon…

no

Jul 28th 2010 × using mootools pseudo selectors to SEO check for hidden page elements

This is an interesting one. Basically, there’s a school of thought in SEO that says, you should not apply a display: none CSS property to elements without a valid reason. By valid, it is understood that the hidden content it is somehow interacting with the user based upon events. For example, flyout / foldout menu systems, mouse tips and so forth are acceptable. Hidden text for the purposes of increasing keyword density and SEO relevance is NOT ok.

There are some sites that claim to check what is detectable and what is not but the bottom line is, only one thing will give you a 100% guarantee and control over what your page is hiding and that is reading it from the DOM directly.

I wrote a little snippet through mootools (as all my sites use mootools) that uses a pseudo selector to search for particular style settings.

*UPDATE* if you found this through some SEO tag/search, you should know that this will only work on pages that utilise the mootools javascript framework (link is on the right handside) and in a browser with a console (chrome, safari or firefox with the firebug plugin). With my “usual” type of readers being web developers, I tend to take this for granted.

// for mootools 1.2
Selectors.Pseudo.style = function(key) {
    var styles = key.split("=");
    return styles.length == 2 && this.getStyle(styles[0]) == styles[1];
};

// output all elements with display: none to console
$(document.body).getElements(":style(display=none)");

Just open your page, open up firebug and the larger command line console and paste (or make a bookmarklet).

Neat or not? You can also look for visibility: hidden or other tricks you can think of (positioning and so forth may need some changes to the code).

note: for mootools 1.3 and slick (still in beta), you need to change this to:

Slick.definePseudo('style', function(key) {
    var styles = key.split("=");
    return styles.length == 2 && this.getStyle(styles[0]) == styles[1];
});

I hope it helps you – it’s a useful trick anyway, you can use this to select all elements with color: red, for example.


Jul 15th 2010 × protecting private class methods in mootools

This is a bit of a sore topic as it is often being asked by people on forums and sites like Stack Overflow. Essentially, javascript does not offer a meaningful way to protect methods from being called directly. Come to think of it, neither does mootools–at least not officially.

However, there is a private API (meaning, not supported) that allows you to do it – its via .protect()

Here is a simple ninja class that shows how we can prevent our ninja from being killed directly without receiving damage first:

var ninja = new Class({
    Implements: [Options,Events],
    options: {
        startHealth: 10,
        name: "Bruce",
        surname: "Lee"
    },
    initialize: function(options) {
        this.setOptions(options);
        this.health = this.options.startHealth;
        this.alive = true;
    },
    heal: function(points) {
        if (!this.alive)
            return;

        this.health += points || 1;
    },
    hurt: function(points) {
        if (!this.alive)
            return;

        this.health -= points || 1;
        if (this.health <= 0)
            this.die();
    },
    die: function() {
        this.alive = false;
        this.fireEvent("death", this); // let everyone know
    }.protect() // protected method
});

var bruce = new ninja({
    onDeath: function() {
        // default handler when death occurs
        alert(this.options.name + " " + this.options.surname + " has passed away.");
    }
});

bruce.hurt(5);
try {
    // not allowed to kill ninja directly, need to hurt it instead
    bruce.die();
}
catch(e) {
    alert("the ninja lives!");
    alert(e);
}

// now hurt it more so it dies anyway
bruce.hurt(5);

The .protect() will cause any attempts to call .die on the instance directly to throw an exception and fail. Once again - although this works with mootools 1.2.4 and on mootools 1.3 nightly build, it's not documented and is unsupported - don't rely on this too much (may disappear in mootools 2.0, perhaps). Still, a nice feature to have at hand, certainly

Check the jsfiddle to play with it some more: http://www.jsfiddle.net/dimitar/jQW5q/


Jul 9th 2010 × Create bit.ly addresses on the fly with mootools and Request.JSONP

I was writing my own re-tweet class and found that I need to crunch URLs on the fly to make them fit within the 140 character limit on Twitter. Come bit.ly and their API, easily accessible via REST and with a JSONP callback interface, just the job for extending Request.JSONP:

Request.bitly = new Class({
    // shorten urls via bit.ly
    Extends: Request.JSONP,
    options: {
        log: !true,
        bitly: {
            api: "R_e744c730bdde44a7eacc88cb892074e7", // GET YOUR OWN API KEY
            login: "webtogs2" // GET YOUR OWN LOGIN
        },
        url: "http://api.bit.ly/v3/shorten?login={login}&apiKey={api}&longUrl={longUrl}&format=json"
    },
    initialize: function(loc, options) {
        this.parent(options);
        this.options.bitly.longUrl = loc;
        this.options.url = this.options.url.substitute(this.options.bitly);
    },
    success: function(data, script) {
        this.parent(data, script);
    }
});

This is the class, now for the example uses, this will convert all links from the page into bit.ly URLs (if they are shorter than the original)

document.getElements("a").each(function(el) {
    new Request.bitly(el.get("href"), {
        onSuccess: function(data) {
            if (data && data.data && data.status_code == 200) {
                var orig = data.data.long_url, hash = data.data.url, difference = orig.length - hash.length;

                if (difference > 0) {
                    el.set({
                        href: hash,
                        title: hash + " - saved " + difference + " chars"
                    }).addClass("shortened");
                }
                else {
                    var error = "ERROR:\n your bit.ly hash '" + hash + "' is longer than the original '" + orig + "'";
                    el.set("html", el.get("html") + error);
                }
            }
        }
    }).send();

});

See it all in action on the little jsfilddle here: http://www.jsfiddle.net/dimitar/xVtZy/


Jul 7th 2010 × code your own facebook ‘be the first to like’ with mootools

I never like having iframes in production sites source codes so when management decided to add the ‘facebook like’ widget thing, I decided to move it outside of the source and into a javascript abstraction. Easiest and most convenient way to do so is via extending the Element prototype in mootools (via Element.implement()):

Element.implement({
    facebookLike: function(url, options) {
        var options = $merge({
            show_faces: "false",
            layout: "standard",
            width: 450,
            action: "like",
            font: "lucida grande",
            colorscheme: "light",
            height: 30,
            href: url
        }, options);

        var src= "http://www.facebook.com/plugins/like.php?href={href}&layout={layout}&show_faces={show_faces}&width={width}&action={action}&font={font}&colorscheme={colorscheme}&height={height}".substitute(options);
        return this.adopt(new Element("iframe", {
            styles: {
                border: "none",
                overflow: "hidden",
                width: options.width,
                height: options.height
            },
            id: "FBFrame",
            frameborder: 0,
            allowTransparency: "true",
            scrolling: "no",
            src: src
        }));
    }
});

// exmaple use:
document.id("like").facebookLike("http://fragged.org/", {
    width: 400,
    height: 30
});

Why would you want to do that instead of the default interface? Because it will speed up page load and abstract this into domready / onload events. It also allows you to produce multiples very easily via a a selector, eg,

// if in your markup you have a number of


// then target them, get the link's href and apply the like button instead
document.getElements("div.like").each(function(el) {
    var urlToLike = el.getFirst().get("href");
    el.empty().faceboookLike(urlToLike);
});

All of the facebook options like button plugin are “supported” – you can find the list here

Finally, here’s what it looks like:

Play with it some more on the jsfiddle: click here


Jun 3rd 2010 × beware: googlebot understands javascript, mootools and ajax now

This came as a complete shock to me: due to the Google Mayday update, I have been monitoring how the bot accesses our sites in a futile search for clues as to the page rankings changes. Very surprised to discover googlebot fetching URLs that are _strictly_ available through Ajax only.

Here is a sample request from earlier today that fetched a small worker thread that produces additional product images:

66.249.65.25 - - [03/Jun/2010:11:25:43 +0100] "GET /angles.php?id=102257&version=Brown HTTP/1.1" 200 801 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"

We have all spoken of Google’s increased capability of following and deciphering javascript logic but it goes beyond the scope of reasonable effort, in my opinion. Is the scraping done based upon URLs detected in the javascript blocks or does it actually evaluate, run and monitor the calls? If the scraping works based upon regex that catches URLs, would obfuscation / base64 encoding help? Does googlebot support XHR via POST or only via GET? Too many questions without an answer at this point, I will update this post as more info becomes available to me.

Such fetches can often be undesirable–certain AJAX calls we do are tied in with sessions and can cause errors / notifications when being requested w/o due cause, session or event. I am currently trying to find if there is a plausible way to apply a “nofollow” to such calls at all that does not involve a lot of editing and blocking of googlebot from any scripts that it has no place reading. If it comes to it, I will revert all ajax handling to a /xhr/ folder and disallow it in robots.txt, wonder what the best practice is…

As for the Mayday Update, the less said about it, the better. I have never seen Google SERPs get things so very wrong – for instance, ranking disabled products with 0 links anywhere on the net that redirect their traffic instead of what used to be the landing pages. Longtail relevance? With 2k organic in-links to the landing page, PR4 and quality content built over 2 years, this is not bizarre enough…