API page: https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_...
In my theme template.php I have a number of files that I add using drupal_add_js. When aggregation is turned on, these files do not get captured. If they are supposed to appear in a aggregated "JS_THEME" file, all that is there are semi-colons (;).
In this example below, these files should get aggregated but they are gone and just 2 semi-colons are there. I actually have a larger number of files and have tried them one by one, two at a time, all of them etc. They do not ever appear in a aggregated file. I have tried using preprocess => true and cache => true. They do not aggregate so I have to use preprocess=>false on each one when aggregation is turned on otherwise they're gone.
function wkh5_preprocess_html(&$variables) {
drupal_add_js('/sites/all/themes/mytheme/js/iframe-resize.js',
array(
'type' => 'file',
'group' => JS_THEME,
'weight' => 1,
)
);
drupal_add_js('/sites/all/themes/mytheme/js/mytheme-js.js',
array(
'type' => 'file',
'group' => JS_THEME,
'weight' => 2,
)
);
}My scripts are only partially updated and I am wondering if the nomenclature for using the behavioral stuff (Drupal.behaviors.exampleModule = { attach: function (context, settings) { etc etc) is required.
Example of my script function syntaxes (all are wrapped up this way):
jQuery(function($) {
$('#dongle .head').click(function() {
$(this).next().toggle('slow');
return false;
}).next().hide();
});The scripts/functions I am using all work fine, they just do not aggregate anything but a semi-colon for each script. The preprocess_html function wraps up a number of drupal_add_js & drupal_add_css files (7 css, 6 js)... none of them get aggregated.
Where am I going wrong? Does this issue belong here?...
Comments
Comment #1
cilefen commentedThis is not a complete answer however you should move to the #attached syntax because drupal_add_js() is deprecated.
Comment #2
dcam commentedCheck out https://www.drupal.org/node/756722#using-jquery. It might fix the problem.
Comment #3
nevets commentedSince you are adding the files unconditionally, I would place these in the theme's .info file instead of adding in the way you are.
The script you are showing is problematic in two ways, it does not follow the Drupal approach using behaviors, and because it does not wait for the dom to be loaded, it may not find '#dongle .head'
Comment #4
jhodgdonThis is not a documentation issue, it's a programming support request...
I'm sorry, but although you can create issues in Drupal Core and mark the category as "support request", we don't normally handle support requests in the Drupal Core issue queue as a regular practice (that option is mostly there for filing support issues for contributed modules and themes).
There are several support options listed if you click on "Support" at the top of Drupal.org, which will take you to:
http://drupal.org/support
There you can find out about the Drupal IRC channels, and the Forums, which are our two main support mechanisms in the Drupal community. You might also try http://drupal.stackexchange.com/
Good luck with your issue!