XBLinJS is an implementation of XBL-style widgets in pure, cross-platform Javascript, DOM 1, and CSS 1. (Higher levels of those technologies may be used, at the corresponding cost in cross-platform compatibility.) It provides the benefits of XBL in cross-platform HTML, and experimentally, provides a most-feature replacement for XBL in Mozilla development. (XBLinJS can be used selectively, too; you need not convert an entire existing XBL application over.)
In addition to that fundamental capability, XBLinJS implements several web widgets for use in web pages, which may be seen on the demo page if you are using a compatible browser.
XBLinJS is targetted at experienced Web developers looking for a framework to organize and abstract out large chunks of dynamic, client-side code, often with AJAX-style code. XBLinJS in particular is designed for situations where you know the user has Javascript turned on and you do not need to worry about "graceful degredation", which mostly happens in corporate/enterprise environments. It is not for casual website operators or people looking for quick code hacks for their webpages. (You are welcome to poke around and use what you can, of course, but be aware you are not the target audience.) Later versions of this library will most likely address that need.
Vital links:
- Download (via CVS)
- Sourceforge Home
- Documentation (all documents have live examples):
- Widgets Foundation: A detailed overview of the foundational class of the library.
- API documentation for all Widgets and all other library support XBLinJS provides.
- What is XBL?
- Mailing lists:
- xblinjs-user: discussion of use and further development.
- xblinjs-cvs: all CVS commits.
- Development blog (RSS)
I believe the Widget interface is now stable, though implementation may continue to be tweaked. Various widgets are always at various states of readiness.
The implemented widgets should be considered lightly tested; in the browsers I can test them in, they are being used at a near-production level, but I have not tested them in Konqueror, IEs before 6, etc.
XBL allows you to bundle up behavioral code with a specification of what the widget contains (panels, buttons, etc.) as one unit, very analogous to how OO bundles data with code. In fact, the cost/benefits tradeoff is almost identical to OO vs. conventional procedural. XBL is a powerful idea, but it has been commonly observed that XBL the technology does little that Javascript can't do, other than tap into the extra widgets that XUL has.
XBLinJS provides a Javascript library that makes it easy to obtain the advantages of this containment while still working in pure Javascript and standard DOM, making it possible to obtain the vast majority of the benefits of XBL across all browser platforms. Rather than "bindings", we talk of "widgets" (and the .js files are generally based on that name).
In fact, anything based on DOM, Javascript/ECMAscript, and the DOM event model can use XBLinJS; currently it is working in cross-platform HTML and experimentally as a direct replacement for XBL with XUL.
XBLinJS also brings some unique advantages that pure XBL does not have:
- Since it is pure Javascript(/EcmaScript) and DOM, it is purely standards compliant and thus can offer the strongest guarantee that it will still work in future browsers when used with HTML, even non-Mozilla ones.
- Even in Mozilla XBLinJS with HTML tends to be more stable than XBL with XUL in Mozilla. (The implementation of XBL has a couple of quirks due to some design decisions, and is also quite spotty, causing a lot of random browser crashes if you push it at all.) There is experimentation with XBLinJS and XUL, more info as it becomes available. (But my reasonable expectation is that XBLinJS + XUL will be significantly more stable than XBL + XUL.)
- As Javascript, it is much more transparent to the developer and easier to debug. The full XBLinJS widget's code is available in Venkman, for instance. It is also easier to test with JSUnit since it is driven entirely by Javascript.
This is the sedate, polite version. A more detailed indictment of Mozilla's XBL implementation is available here; those who simply want to Get Work Done should be warned that while that is not purely a rant (in general, a ranter just complains and does not provide solutions, whereas I am at least trying to provide solutions via this library), it still strongly resembles one. I prefer to think of it more as a "strongly worded warning".
Currently, the Widgets shipping with this library are rather limited in scope, excepting the ported Javascript Console. This is because the focus has been on getting the library solid and feature-rich enough to be pleasant to use. In my own custom code, I have some quite sophisticated Widgets, they just aren't suitable for public consumption. Target developers are those who will be creating their own Widgets for their own apps.
- To replace, to the extent possible, all features of XBL that can be reasonably replaced, while still retaining cross-platform compatibility in the official version of the library.
- To surpass XBL in ways in which it makes sense; for instance it is easy to add more flexible support for "inheritance" in JS. (For instance, see how the Javascript Console implements "history" support, with a generic "history" mixin instead of hard coding it into the object.)
- To augment the library with the addition of several fully-fledged example widgets that are also useful to developers.
- To provide testing via JSUnit.
- Any kind of XBLinJS widget that seems generally useful to many people.
Additional ideas the project manager has no intention of pursuing but would make interesting additions:
- A script to convert existing XBL files into XBLinJS widgets. (Not to hard to do a lot of the grunt work. Essentially impossible to do the full conversion automatically. Still a net gain.)