Fork me on GitHub

üjs - JavaScript with röck döts, mötherfücker

v1.0 released April 1, 2011

Today's JavaScript developers need fewer well-designed, battle-tested, comprehensive JavaScript toolkits and more one-off, disconnected, and gratuitious JavaScript libraries. Why stand on the shoulders of giants when you can command an army of midgets?

S̈ize

Let's face it: if a JavaScript library can't fit into a tweet after gzip, then it probably contains lots of unnecessary bloat that increases download times for your users. For this reason, üjs offers an efficient, compact API whose minified version is a mere 134 bytes when gzipped.

N̈amespace

As every good JavaScript developer knows, it is best practice to load as many JavaScript libraries as possible onto your page (always synchronously, just after the opening <body> tag). Loading multiple libraries with duplicate functionality begets redundancy, and redundancy minimizes downtime.

Because you will probably want to use üjs alongside some other popular libraries which have already claimed the “good” single character namespaces, üjs takes full advantage of Section 7.6 of ES5, which explains:

Unicode escape sequences are also permitted in an IdentifierName, where they contribute a single character to the IdentifierName, as computed by the CV of the UnicodeEscapeSequence (see 7.8.4).

ÄPI

As explained above, the üjs API is lean to improve performance. Only the most critical functions for JavaScript developers are included in the library, of which there are two:
/**
 * Adds umlauts to lowercase vowels in a string.
 * @param {string} str
 * @return {string}
 */

var ü = function(str) {
 
return str.replace(/[aeiou]/g, function(ch) {
   
var m = {
      a
: 'ä',
      e
: 'ë',
      i
: 'ï',
      o
: 'ö',
      u
: 'ü'
   
};
   
return m[ch] || ch;
 
});
};


/**
 * Spin̈al Tap amplifier volume normalization.
 * @param {number} num
 * @return {number}
 */

ü.n̈ = function(num) {
 
return num < 11 ? 11 : num;
};
You can see sample usage of üjs in the accompanying unit test.

Ïnternationalization (ï18n)

Are you kidding? üjs has international characters in the fucking name! How much more ï18n support could you possibly need?

Öpen Source License

Although there are plenty of existing software licenses available today, none of them appropriately convey the raw power of üjs, so naturally, we had to write our own. Because we could not afford any real lawyers, we decided to adapt the üjs license from the NTP License. Although üjs has little to do with the network time protocol, the NTP license was one of the shortest we could find, and therefore, the easiest to adapt:
Copyright (c) üjs 2011

Përmïssïön tö üsë, cöpy, mödïfy, änd dïstrïbütë thïs söftwärë änd ïts döcümëntätïön för äny pürpösë wïth ör wïthöüt fëë ïs hërëby gräntëd, prövïdëd thät thë äbövë cöpyrïght nötïcë äppëärs ïn äll cöpïës änd thät böth thë cöpyrïght nötïcë änd thïs përmïssïön nötïcë äppëär ïn süppörtïng döcümëntätïön, änd thät thë nämë üjs nöt bë üsëd ïn ädvërtïsïng ör püblïcïty përtäïnïng tö dïstrïbütïön öf thë söftwärë wïthöüt spëcïfïc, wrïttën prïör përmïssïön. üjs mäkës nö rëprësëntätïöns äböüt thë süïtäbïlïty thïs söftwärë för äny pürpösë. It ïs prövïdëd "äs ïs" wïthöüt ëxprëss ör ïmplïëd wärränty.