Slashdot Mirror


A Good Resource for Learning XUL & Javascript?

RJabelman asks: "I'm trying to write a Mozilla extension, but I can't find a decent resource to learn from. Tutorials abound for packaging up an extension, and the web's littered with Javascript snippets to pretty up a web page, but there seems to be very little authoritative information for doing serious work with Javascript, XUL and Mozilla (and more specifically, manipulating XML). I can find my one true resource for every other language or API I've learned: but not this. Can anyone point me to theirs?"

4 of 82 comments (clear)

  1. OReilly book by mrblah · · Score: 5, Informative

    There's an OReilly book, if that helps.

  2. RAD With Mozilla, Bruce Perens OSS series by LOBOestepaRIO · · Score: 5, Informative

    It's fairly good, and available for free in PDF. http://phptr.com/promotion/1484?redir=1

  3. XUL links by nitro322 · · Score: 5, Informative

    If you're just starting out with XUl, you may want to brish up on your JavaScript first. Although XUL itself is a rather straightforward markup language (albeit with many, many quirks), in order to make your app actually do anything, you'll need to write some JavaScript to control it. There are many, many Javascript resources out there, and I also recommend JavaScript: The Definitive Guide from O'Reilly.

    Once you have that down, here are a few XUL sites I recommend:

    Creating Application with Mozilla - Online version of O'Reilly's book. Great resource for beginners to follow through, but some of the examples no longer work due to changes in the APIs since the books release.

    XUL Planet - An excellene resource for XUL developers of any level. This site contains a great tutorial for getting started and becoming familiar with the environment, as well as a definitive reference guide for XUL and XPCOM objects and functions.

    XUL Planet Forum - This forum is also housed at the XUL Planet website, but it deserves separate mention. This is the only forum/newsgroup/list I've been able to find that's still active and populated with friendly and helpful souls. I've received helped there several times on problems I'd been working on for weeks or months.

    There are also a few XUL-related newsgroups on mozilla's usenet server (eg, news://news.mozilla.org:563/netscape.public.dev.xu l), though not too many people use those groups anymore.

    There's also Mozilla official XUL Programmer's Reference. This is a great reference resource, but it's not geared for beginners.

    And finally, the mother of all example sites: http://www.hevanet.com/acorbin/xul/top.xul If you can't figure out how something work, this most likely has a working example.

    Good luck!

  4. Re:XulPlanet by Jerf · · Score: 5, Insightful

    On the down side, welcome to the land of magic and wonder, where arcane bugs haunt the long forgotten planes of DOM...

    Yeah, I dug into Mozilla development gung ho over the past year or so, and I've completely abandoned it... well, I'm in the process of creating a replacement XBL, but after that's done, I'm out. In painfully slow succession, I've tried in a serious way Moz's RDF support, XUL, and XBL, and in every case I have rapidly exceeded their capabilities (to the tune of segfaults) and gone back to JS + DOM. (For RDF, I now dump out my data as a JS file and use XMLHttpRequest to retrieve it and "eval" to run it; this is what Google Suggest uses. I beat them by about a month, I know others beat them by more :-) but it works and you'll be stunned how fast it is, even for many kilobytes of data; by far the fastest solution I've found, even independent of the fact that loading any sort of XML in Moz causes a huge stall of some kind and tends to cause crashes and memory leaks in nothing flat.)

    I'm preparing a series of half rants, half detailed indictments on why the Mozilla specific technologies are not just poorly implemented at the moment for any task other than being a web browser, but why Javascript + DOM is usually, on the balance, a superior solution. ("On the balance" means that while my JS implementation of XBL is neither a subset nor a superset of "true" XBL, on the whole the benefits level out in favor of my JS implementation... and if I were willing to go pure Moz instead of cross-platform it would be a total win.) I don't want to repeat them here in toto, but, well, that's actually the basic argument: Me, a single schmoe, can replicate most of XBL in a couple of weeks, in Javascript, and it is actually much more reliable too, for reasons that will only make sense if you used Moz's XBL support for anything serious, like widgets that can load remote data or include other widgets in interesting ways. How much time has been spent on XBL, which is still behind?

    Unless you need a XUL widget like "popup" that has no good HTML replacement, you're just better off with JS and DOM. Most people don't understand how powerful JS really is, and I've found it to be surprisingly speedy, too.

    (To show I'm not just spouting off randomly, here is my current XBL in JS implementation. Still in development, but it oughta show I'm serious about this, and even now I'm finding it more pleasing to work with overall than real XBL. What stops me from releasing the rants right now is, well, there's some writing to be done yet, but instead of just bitching I want to have some constructive solutions as well; xbl.js is a big part of that, and right now I'm working on the POPUP element because I need that for my app. Ranting is great but I find they are even more powerful when they are not purely negative.)

    Details forthcoming at a later date, but next time you're reaching for XUL or XBL, if it isn't for a Mozilla extension, stop and make sure you don't really want to do it in cross-platform JS + DOM. See, the thing is, those libraries are well tested and optimized in a variety of situations; I'm not encountering bugs hourly like I felt like I was in Moz.

    Finally, to preempt some of the obvious responses, I'm not saying XBL or something was a bad idea; in fact the idea is so good I'm re-implementing it. I'm saying the implementation right now is so dodgy it isn't worth playing with when there is another less cool, but more functional, alternative available today in the form of JS + DOM.... and what advantages XUL or XBL have over my JS implementation are only a few small hooks away from being exposed to the JS as well.