Introducing Bicycle 1.2: a lightweight JavaScript library

Homepage > Diary > Coding > Introducing Bicycle 1.2: a lightweight JavaScript library

Mon 06/15/2009

in Coding, JavaScript, Projects

When i first stepped into JavaScript i found that one of web developers’ common practice  was collecting  snippets of code (in form of prototypes, functions and shortcuts) to overcome both known JavaScript missing features and language’s verboseness.

Day by day, i’ve understood why so many developers use libraries (or frameworks) such as Mootools or jQuery: It’s a matter of typing.

document.getElementById("test"); //native Javascript
$("#test"); // with jQuery

At the same time i’ve learnt that libraries aren’t always worth their weight. Small projects don’t need them, and just writing a shortcut like:

function id(string) {
   return document.getElementById(string);
}

can make your life better (and more lightweight).

Introducing Bicycle 1.2

Bicycle 1.2That said, here is a new version of Bicycle, my little “JavaScript Collection”. As from the name, it’s a lightweight and load-cost-effective library (about 9Kb minified) with everything is needed to keep your code simple and cross-browser. Here is a sample code:

var el = $getEls("test");  // get the element with id "test"
var input = $TN("nametext");  // get the first element with name "nametext"

Chainability

Anyway, if you need something more, since this new version Bicycle features a convenient chainability wrapper, with even new methods such as mouse and DOM-ready events and AJAX handling.

The chainable structure is bound to the $b namespace, so that you can use it along with other libraries. Here is a sample code:

$b("#test").css("color","red").txt("New text!");

See the documentation for more methods.

Form Handling

Finally, as a bonus, i’ve added a smart piece of code called Telegraph, which is basically a form handling library to quickly get and manipulate form inputs:

$b.getForm("myForm").value("testinput"); // get an input value
$b.getForm("myForm").serialize(); // serialize form data in a JavaScript object

Grab a copy

At last, more code can’t mean same weight, but i suppose you won’t mind it, ’cause  Bicycle core + chainability + new methods + Telegraph is just 22Kb minified.

Head to the main project page to get more infos and documentation, or grab a copy of the source code and “take a ride” with your brand new Bicycle.

Share this:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • BlinkList
  • blogmarks
  • DZone
  • LinkedIn
  • MySpace
  • NewsVine
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Ping.fm
  • Yahoo! Buzz
No Related Posts

Tags: , , , ,

Leave a Reply ()

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

* required.