people often report problems related to dynamically adding css/js files to ajax-popups while css/js optimization is enabled in drupal performance settings. Maybe the use of ajax_load could help solving this issues?

http://drupal.org/project/ajax_load

Comments

sandfurz’s picture

i digged a little deeper into that issue:

The popup-content (fetched as JSON-object) contains a script-array, representing the js-files required by the new content within the popup. That array is compared against the scripts included by the current page - by using jquery-selector $('script[src]') - so that only the new files will be loaded.

If there is no javascript aggregation enabled, this works perfectly well!

Once you enable javascript optimization (admin/settings/performance => optimize javscript), there is only ONE js file included on the page, so $('script[src]') won't find *those* scripts, that have originally been aggregated into that file.
Now, loading new ajax-content, the complete js will be included again, even if it's already present within the aggregate-file, sometimes resulting in weird browser-crashes due to recursion.

Maybe we could store all original js-paths into a js-variable (using a module_page_preprocess?), so we can compare against *this* var instead of using $('script[src]')?
I don't know if it's feasable, but that would probably be a great improvement. Maybe i'll check this out, once there's some spare time :-)

sandfurz’s picture