Module must explicit the dependency from jQuery Update

Kiam@avpnet.org - May 23, 2008 - 12:41
Project:Ext
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:ximo
Status:closed
Description

I would change the code from:

/**
* Loads Ext.
*/
function _ext_load_ext() {
  $ext_path = variable_get('ext_path', 'sites/all/modules/ext/ext-1.1.1/');

  // Load Ext adapter, library and stylesheet.
  drupal_add_js($ext_path .'adapter/jquery/ext-jquery-adapter.js');
  drupal_add_js($ext_path .'ext-all.js');
  drupal_add_css($ext_path .'resources/css/ext-all.css');
}

to:

/**
* Loads Ext.
*/
function ext_load_libraries() {
  static $done = FALSE;
 
  if (!$done) {
    // Load Ext adapter, library and stylesheet.
    $ext_path = drupal_get_path('module', 'ext') .'/lib/';
    drupal_add_js($ext_path .'ext-all.js');
    drupal_add_css($ext_path .'resources/css/ext-all.css');
    $done = TRUE;
  }
}

The function would be called from any third party module that would need to use the Ext JS library, and the library would not be included if not necessary. Using the Ext JS version 2.1 or higher there would not be the need to include the Ext-jQuery adapter, that is not even necessary in a Drupal powered web site (as the jQuery library is always loaded, and it does not interfere with Ext).

#1

ximo - May 24, 2008 - 00:53
Assigned to:Anonymous» ximo
Status:active» fixed

Thanks man! I've implemented your suggestion on the static check. The initial commit of the module was very basic, it was really about time I made it more stable. I also added some new features, check out the latest code from HEAD.

As for the jQuery adapter, that is actually needed. It works as a bridge between jQuery and Ext and is required for Ext to function on top of jQuery.

#2

Kiam@avpnet.org - May 25, 2008 - 02:14

Ext JS doesn't need jQuery to work.
As a prove of what I say there are just 8 functions in the source/adapter/jquery-bridge that call the jquery() function (compare then with source/adapter/ext-base to see how little the difference is).

Ext JS works well without jQuery, and the demoes they set in their web site don not even load it (see here).

#3

ximo - May 25, 2008 - 22:58

You're right that Ext works fine without jQuery. But if you don't use jQuery as its base, you'd need to load the Ext base (ext-base.js). And that file is 28 KB minified, which is 20 KB more than the jQuery adapter. jQuery is loaded by Drupal anyway, so using the Ext base instead would only add 20 KB to the page load compared to using the adapter.

#4

Kiam@avpnet.org - May 26, 2008 - 14:23

That is true, but there is also a side effect on using the jQuery adapter. You don't know which version of jQuery Drupal comes with, and you don't know if the adapter would work with every version of jQuery.
In other words, that creates a dependency that is not necessary, and just to save 8 KB from a library that already uses 523 KB.

#5

ximo - May 27, 2008 - 08:17

Well, according to this blog post, the Ext and jQuery teams work together to ensure that Ext works with the latest version of jQuery. If the jQuery version shipped with Drupal isn't supported by Ext any longer, there's always the jQuery Update module that gives you the latest version of jQuery. As of today, Ext requires jQuery 1.1 and up, which means that Drupal 5 users need to update their jQuery version, while Drupal 6 users needn't do anything. The D5 version of this module could require jQuery Update though..

#6

Kiam@avpnet.org - May 27, 2008 - 16:56

That is my point. Drupal 5.x comes with jQuery 1.0.1, so Ext JS will not work with that version of Drupal.
At this point, the alternative for the ext.module 5.x are just two.

#7

Kiam@avpnet.org - May 27, 2008 - 17:01
Title:Modify to the source code» Module must explicit the dependency from jQuery Update
Version:6.x-1.x-dev» 5.x-1.x-dev
Category:feature request» bug report
Status:fixed» active

In any installation of Drupal 5.x, Ext JS doesn't work if used with the jQuery adapter.
The module needs to explicitily declare its dependency from jQuery Update, which is the only way to be sure a Drupal installation uses jQuery version 1.1 or higher.

#8

ximo - May 27, 2008 - 23:43
Status:active» fixed

Fixed it now.. thanks!

#9

Anonymous (not verified) - June 10, 2008 - 23:44
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.