I was reviewing a vote up/down issue: #972386: Clicking widget causes module CSS files to be reloaded when CSS optimization is enabled, and I could not solve it for now from vote up/down module. So I started to search at ctools. #830382: Unwanted / duplicated temporary css files if CSS Optimization is enabled. seems to be like the more related, but it was closed two time now saying ctools is not used in the right way, #745468: ctools_ajax_command_scripts() in ctools_ajax_render() causes unwanted scripts to be loaded (and potential js conflicts) seems to be related, but I could not really find a good relation, so I am starting another issue.

I end up noticing that, when core css/js optimization is active, and I try to use ctools_ajax_render(), many js/css are loaded in the ajax render.

To see an example of it:

  • Install drupal
  • Use zen theme(that would help to show how zen css is overwritten, ex. at tabs)
  • Enable vud_node(dependencies: vud, ctools and votingapi) and configure it to story node type
  • Create a story content
  • Enable core css optimization
  • Go to the node and try to vote

Another way to notice this is just see at firebug loading css/js on ajax callback.

I really do not know if I am solving this in the right way, but I added a patch that seems to be solving the problem.

In the other side, I also tried to trace where exactly this started to happen with git bisect, and the conclusion was edc5325.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jthomasbailey’s picture

testing it out, so far so good

naden’s picture

Thanks, works for me!

Ainur’s picture

marvil07, doesn't helped me. Still got js and css file processing which slows down the voting significantly using Vote Up/Down.

jthomasbailey’s picture

It is noticeably slower, anyone know if it's actually downloading the css and js everytime a vote is cast? That would be very bad.

merlinofchaos’s picture

Status: Needs review » Needs work

This patch doesn't make any sense. It basically completely breaks the lazy-loading of CSS files because $css_files will never be populated. Actually worse, I think it will only be populated for 'theme' files which will cause them to totally break.

So if by 'work' you mean 'breaks everything this code is intended to do' then I guess it works. My definition of 'work' is something else.

marvil07’s picture

Sorry for the bad patch, first time trying to modify ctools :-/

This is another attempt, hopefully better :-)

I a attaching two files: the first one with non-relevant-space-changes(formatting stuff included) and the second one without it(formatting stuff not included).

marvil07’s picture

merlinofchaos told me to try to modify overwriting logic without using the global variables at DB on IRC, so here another try based on the preprocess attribute.

marvil07’s picture

Status: Needs review » Needs work
FileSize
798 bytes

Ok, merlinofchaos comment me I am in the wrong path to solve this problem, since I am breaking the code :-(

So, I end up writing a pretty small module for showing the bug clearly(please use zen theme to notice quickly how tabs style change when the ajax link is pressed). Hopefully that help other people to try to solve the problem.

jthomasbailey’s picture

Status: Needs work » Needs review

#7 is working, much faster. Thanks Marvil

gausarts’s picture

Subscribing. Noticing this since 6.x-1.6. Thought was normal. The only obvious sympton: CSS was screwed after clicking VUD link. It surely displays fine again after reloading. Thanks.

carlop’s picture

Subscribing

gibbet’s picture

How do we fix this? My site falls apart if i allow ajax and vote up down...

doublejosh’s picture

I have the same double loading issue.

CTools AJAX reloads all of my CSS and JS files that are already present with performance caching on.

The error happens with FB Social (like button) but that's just the unfortunate victim of the double loaded files.

Ainur’s picture

Status: Needs review » Reviewed & tested by the community

marvil07's patch #7 works very well. Tested on large comunity site.

doublejosh’s picture

Updating to 6.x-1.8 worked for me... on enterprise site.

merlinofchaos’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

Ok, finally took a look at this. This patch is still wrong, and here's why:

The test module is not doing a ctools_include('ajax') when it's doing a ctools_include('ajax-responder.js'); Because ajax.inc is not included, CTools' preprocess is not putting the list of .css files aggregated onto the page (because it doesn't think it needs them).

I suspect this is also the problem in vud. When I patched that stuff in, I probably didn't thik to do a ctools_include('ajax'). My bet is that is all you need to fix this.

Can you try that?

marvil07’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

I have just tested the module on #8, and as merlinofchaos mentioned, the problem is on the implementation, not on ctools, mystery solved \o/, now riunnin gto vud to fix this ;-)