X v/s CBE

The following discusses the differences and similarities between the X library and the CBE API.

Differences & Similarities

Differences

Most of the CBE documentation does not apply to X. CBE implements its own object tree. CBE also implements the DOM2 event model in cross-browser javascript. The CBE documentation is needed to describe these 'embedded' object and event models.

X does not implement its own object nor event models. You might say that, while CBE is an 'API', X is merely a function library. X uses the browser's native object and event models. Really, the only documentation you need to make use of X is...

  • the X function reference, which describes how to use each function
  • a small example of using the function (i'm working on more examples)
  • DOM documentation from W3C, MS, NN, etc.

So, you don't have to learn the X object model, because it doesn't have one - just study the existing browser DOMs.

Almost all the CBE methods are tightly bound, because of their dependence on the CBE object model. Most of the X functions are independent from each other. With X it is much easier to create a custom 'x.js' file which contains only the functions used by your application. (I'm working on something that will automate this. ;-))

Similarities

The semantics of CBE methods and their corresponding X functions are virtually the same. For example, the concept of "width/height" is the same - the CBE methods width()/height() and the X functions xWidth()/xHeight() both provide, effectively, read and write access to element.offsetWidth/element.offsetHeight.

Related Articles

Getting Started with X.