Having:

  drupal_add_js(drupal_get_path('module', 'filefield') .'/filefield.js');

... in hook_init will stick the filefield JavaScript on every page, no matter if it's required or not. Would be nice to only add it when it's needed.

CommentFileSizeAuthor
#3 349319.patch1.27 KBRobLoach
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Flying Drupalist’s picture

But if you use javascript aggregation then it shouldn't matter. Having them separately requires you to load a different aggregated js for different pages, which would nullify any gains from loading separately.

RobLoach’s picture

One of my sites, I don't use JavaScript at all. So the page is being rendered with jQuery, FileField and Drupal.settings.basePath, and isn't even using them. Would be nice to only include it when it's required. I'll have a look at this on Monday.

RobLoach’s picture

FileSize
1.27 KB

This patch only presents the JavaScript file when the file widget is being used.

RobLoach’s picture

Status: Active » Needs review
drewish’s picture

Status: Needs review » Fixed

thanks committed to HEAD.

Status: Fixed » Closed (fixed)

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