Cross - platform wrapper function for JavaScript libraries

Thursday, October 25, 2012 Posted by Ruslan Matveev 0 comments
In old times, when JavaScript libraries had to work only in the web - browsers, common pattern for exporting your stuff into the global namespace was looking like this:

(function() {
    window['MyLibraryMethod'] = function() {
        alert('HELLO WORLD!');
    };
})();

We were just attaching our methods and properties to the global namespace, and this was all fine before somebody come up with the idea to run JavaScript code in non - browser environment. There was no window object so we had to find global object ourselves:

(function(global) {
    global['MyLibraryMethod'] = function() {
        alert('HELLO WORLD!');
    };
})(function() { return this; }.call(null));

Then things started to change very quickly, CommonJS standard and it's implementations against AMD (Asynchronous Module Definition), RequireJS and so on, but how should I package my library so the end - users won't have to repackage it in order to use it?

Mozilla Rhino + CommonJS - making a smart modules

Monday, October 15, 2012 Posted by Ruslan Matveev 0 comments
Hi all, in my last post about Mozilla Rhino CommonJS support I've described the basics. In this post I'll explain you how to organize your code so it can work when there is no CommonJS sandbox enabled. Imagine that we have decided to organize all our Mozilla Rhino libraries as CommonJS modules, but what if there is an old project that has no knowledge of this change, and it still relies on old good load() function that is importing everything into a global namespace? The question is: is that possible to make a library that can work same way with and without CommonJS support?

Using CloudMine to store your application data in the cloud

Saturday, October 6, 2012 Posted by Ruslan Matveev 2 comments
Nowadays HTML5 becomes more and more popular, offline cache can help you when you need to build an application that does not require a web - server, client - side storage can be used to store application data in built - in web - browser database. But what if you need to share application data between users? There are many web - applications that allows you to share your work with the rest of the world, for example jsFiddle allows you to save your code snippet and get a permanent link that you can post in twitter or send to your friend. So how can you make something like this using HTML and JavaScript only?

Histone template engine playground application

Thursday, October 4, 2012 Posted by Ruslan Matveev 0 comments
Histone template engine now has it's own online playground application that allows you to test your templates and play with examples right in your web - browser.

Histone template engine online playground