Home > ExtJS > Introducing wp-extjs-loader

Introducing wp-extjs-loader

February 28th, 2009

Today I wrote my first WordPress plugin. Its purpose is to load the ExtJS libraries into a WordPress post whose category has been set to “ExtJS”… just like the post you are reading now. See, ExtJS is a heavy library, and even minimified it clocks in at nearly 600 KBs. I don’t want to have to pay that bandwidth cost if I don’t have to, nor do my readers who aren’t the least bit interested in ExtJS. So the plugin takes care of loading only when the post is about ExtJS.

I honestly can’t imagine a use for this plugin other than someone who blogs about both ExtJS and non-ExtJS topics. But, if you are interested in the plugin, it is available at github.

A few caveats… this plugin is still very much in progress. The ExtJS category ID is hard coded into the code. So, unless your ExtJS category ID == 10, as mine does, the code won’t work. Future releases will allow you to specify which category to load on… and maybe, down the road, allow you to specify which parts of ExtJS to load, as opposed to the whole suite like it’s doing right now.

But here’s the big payoff for all this work. I give you my first embedded ExtJS example:

Now, if you think that was easy, you’ve got another thing coming… took me forever to get that to work. Not because of the ExtJS, but because of all the stylesheet interference with my kick-ass WordPress theme. But I think I’ve got it all sorted out. Here’s the entirety of the code I used to produce the above.

  Ext.onReady(function() {
    button = new Ext.Button({
      text:     "Click me, I won't bite",
      renderTo: 'example-button',
      handler:  function(){
        Ext.Msg.alert("Congratulations","You clicked me!");
      }
    });
  });

And then I defined a DIV on the page with ID = “example-button”. It’s just that easy. I think all the kinks are finally worked out and we can get into some real learning with the next post.

probonogeek ExtJS

  1. ethan
    February 28th, 2009 at 18:19 | #1

    what purpose does this have?

  2. Alfredo
    February 28th, 2009 at 21:52 | #2

    Let the man play with his toys.

  3. March 1st, 2009 at 08:52 | #3

    @ethan: what purpose does the post have, the plugin have, or ExtJS in general? The short answer for all three is that I feel like there is a dearth of secondary information about ExtJS and since I work with it every day and have overcome many of the initial hurdles, I’m trying to pass on that information.

  1. No trackbacks yet.