Hi,
at first thx for this wonderful module.
From first second up (3 years ago) I used Drupal with ajax xhr-calls. So I like this
module very much. :)
Now I've got a problem while using Drupal 6 Performance features (JS Aggregation) and ajax_load. The js files
that are aggregated are loaded while first (real) page load. After loading content partially with ajax_load by xhr
those js files that have already been loaded are no getting loaded again :(
i.e.
My website uses a "lightbox" script called shadowbox and swfobject. That scripts get aggregated into a single js file.
After clicking an "ajax-link" those files get loaded again.
some idea how to prevent this? this crashs mostly of my js-logic :(
thx and best regards!
melchior
Comments
Comment #1
markus_petrux commentedThis is how it is supposed to work. If a .js file is already loaded, then there should be no need to read it again.
If your .js file needs to be loaded again, then I imagine it contains initialization code that should be implemented using Drupal.behaviors.
I'm not sure to understand your problem, so please correct me if I'm wrong.
Comment #2
markus_petrux commentedAny news? Is it possible that the problem was a result of not using Drupal.behaviors? ...or maybe custom code/implementation of other libraries/modules that is not re-entrant?
Comment #3
markus_petrux commentedMore than one month with no further feedback. Assuming ajax_load was not the cause of the reported problem.
Please, feel free to re-open if you can provide more information. Thanks
Comment #4
markus_petrux commented...it seems it wasn't so critical, after all. :)
Comment #6
sandfurz commentedI think i got the message of the original post, since I encountered the same issue.
Ajax_load checks the currently loaded js-files via jquery-selector using $('script[src]'). The dynamically loadad ajax content (JSON) contains a script-array, representing the js-files required by the new content. These 2 arrays are interesected, 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, so $('script[src]') won't find those scripts, that have originally been aggregated into this file.
Now, loading new ajax-content, the complete js will be included again, even if it's already present within the aggregate-file.
Maybe we could store all original js-paths into a js-variable (using a module_page_preprocess?), so we can compare against THAT 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 :-)
Edit: using popups module (http://drupal.org/project/popups), there is exactly the same problem, since they're doing it in a similar way!
Comment #7
sandfurz commentedComment #8
markus_petrux commented@sandfurz: What you describe in #6 has been fixed already. Please, see: #685918: Drupal.theme functions implemented by other modules are broken when javascript compression is enabled
Try with the latest dev package.
Comment #9
sandfurz commentedgreat!
Thx :-)