Two alternatives for RequireJS

These days I’ve been looking for alternatives to RequireJS.

The reason is that rJS is a little too complex to be worth integrating with it. Not all JS libraries are AMD compatible and this brings an extra overhead. Besides, the setup time for a new project is not fast enough.

I’ve started my search for alternatives. After looking at a few libs at this link [flash content], I’ve ended up with 2 solutions that that I preffer:

  • yepnope js – used by Modernizr
  • labJS – a performance oriented script loader

Top 3 things I like about yepnope js:

  1. Ability to preload scripts without executing them. For example Gmail for mobile uses this technique for performance reasons. AFAIK RequireJS can’t do that.
  2. Ability to load CSS along with the JS files. AFAIK RequireJS doesn’t handle that. Update: as per Patrick’s comment bellow, there is a hook to achieve that eventually. Thanks Patrick !
  3. Ability to insert a test function before loading a script. I’m quoting Modernizr: “combine feature detection with media queries and conditional resource loading. That gives you the power and flexibility to optimize for every circumstance.”

How to build a Flex Mobile App with Maven

Building applications that run on mobile is today’s trend. Everybody is thinking mobile and social and cloud.

To build a Flex application for Mobile is very easy, provided you use Flash Builder. When it comes to automating that build, things are not as easy. Because recently I’ve managed to overcome the obstacles that were preventing me to build a running Flex 4.5 app for mobile, I want to share the build.

I’ve taken the initial build from this thread. Marvin Froeder ( a.k.a VELO ) has been doing some hard work recently, creating the Enterprise version of Flex Mojos. This version seems pretty promising. I’m looking forward for its release. When you’re testing the build, make sure you register during the build, following the instructions. The process is fairly easy, but … rewarding. The maven build creates the final apk/air/exe/dmg…, which you can use to install the app on your device. It’s worth trying it.

To build the app, you need to execute

mvn3 clean install package

Prior to the build, you need to make sure you have Maven 3 installed, with the following environment variable:

MAVEN_OPTS="-Xmx1024m -Xms128m -XX:+DisableAttachMechanism"

Also, you need to have the mobile theme installed in a repository. As of today, the flex mojos repository doesn’t contain this theme, so you need to install it manually.

When the build ends, connect your device to the computer and execute:

adb install -r ./target/mobile-1.0-SNAPSHOT.apk

Then, go to your device and open “main” application.

If you see the following screen, it means that the application got compiled successfully.

Maven Mobile Screenshot

Screenshot showing the app built with Maven