Build your own framework with

EmbedJS


About

EmbedJS is a JavaScript framework for embedded devices (mobile phones, TVs, etc.). It takes a different approach than other frameworks by shipping just the code needed for each device. That means, there's less code going over the wire, less code branching at runtime and less memory usage.

You still get what you'd expect from a framework: multiple platforms — one API.

News

EmbedJS 0.2 is there!

That means besides some small changes and bugfixes, EmbedJS now implements AMD!

For a list of changes, see the changelog.


In action

Here's some example code, covering two very common scenarios:

The first uses the html-element feature that provides the handy create() method, the second one uses the async-promise feature that brings CommonJS compliant promises to you.

These are just some of the many tools that will make your life easier!

For more examples, browse EmbedJS's features and check out the inline docs, or go to the API docs.


Builds

There are dedicated builds on github for following platforms:

  • iOS
  • iOS 5
  • Android
  • Firefox Mobile
  • Blackberry
  • Blackberry 4.6
  • Nokia WRT
  • Vodafone Apps Manager 2.2
  • Windows Phone 7

License

EmbedJS is a Dojo Foundation project.

It's OpenSource and available under either the terms of the modified BSD license or the MIT License. Both licenses grant you broad rights to use and build on and with EmbedJS in both OpenSource and commercial settings.


Usage

There's two ways you can use EmbedJS:

First, you can use a ready-made build. Just include it and you'll have all features availables under a global embedjs namespace.

Or – and we can highly recommend that – you can take advantage of the AMD pattern and the feature plugin!

So, if you want to use features in your module, you'd do the following:

EmbedJS uses a feature plugin to decide what implementation should be used for the feature you are requiring. So, what happens in the first example above, is that the feature plugin gets called and gets handed over the feature name, 'async-promise'. It then looks up the feature name in the implementation map – and then two things can happen: if there's only one implementation of the feature, it will load it. If there are multiple implementations available, it will run a test function for each of them to decide which one to take.
You might want to take a look at the implementation map for unknown platforms (this is the one that contains multiple implementations and tests) and the one for Android (this is a map without tests). In these files you'll also find the complete list of all currently available features in EmbedJS.

To include EmbedJS the AMD style, you need to tell RequireJS where the baseUrl is and what implementation map to use:

Check out the example in the examples directory to see a, well, example!

Features

EmbedJS uses the concept of features: Functionalities are split up into features, as fine-grained as possible, and each feature might have multiple implementations.

The Features are implemented as AMD compatible modules, so if you don't use a ready-made build, you can use a loader like RequireJS to easily pull in the features you need for your project – each implementation of a given feature knows it's dependencies, so you don't have to worry about that.

This way it's super-easy to just use the features you want in a given project – no need to ship code that's never executed!


API Documentation

You can find the API docs right here.

Heritage

EmbedJS is based on the Dojo Toolkit. If you know how to work with with dojo, you already know how to work with EmbedJS!

Testing

To test individual features or specific implementations, go to the tests directory and open the index.html file. It will generate a list of registered features and their implementations – test the ones you're interested in or just hit the "Test All" button!

Getting Involved

EmbedJS is OpenSource. There's two ways you can help to improve it:

First, you can run the tests on any device / browser you can get your hands on. We highly appreciate your feedback and bug reports! Please use github to report bugs. It's your feedback that will make EmbedJS better!

Second, if you find a bug and know a fix, you can of course submit a pull request! We'll get back to you then.

Staying in Touch

To stay up-to-date, why not follow @embedjs on Twitter?

Background

EmbedJS is brought to you by uxebu. We have been successfully using it for quite a while now, and decided that we wanted to release it to the public. If you want to learn more about the backgrounds, the "why"s and "how"s, feel free to contact anyone of the uxebu crew.

You could also check out some presentations regarding EmbedJS.

Even better — attend a talk about EmbedJS! We'll let you know of upcoming talks.

Custom Builds

To create a custom build with the features you are using, you can use the r.js build tool. For detailed instructions, check out the excellent RequireJS documentation.

Family

As you are probably interested in building apps for mobile/embedded devices, have you met apparat.io?