Surely the approach to CSS and JS caching is all backward in ctools at the moment?
Currently the server is trying to keep track of the css and js files sent to the client, and only send ones it doesn't already have. Putting the data in a really fragile cache though, is not a good idea. Try adding a node with a ctools modal, then click another ajax link on the same page, for example.
Isn't the client better placed to know what CSS and JS files it has been sent? Rather than store the array of sent CSS and JS file on the server in a cache, can't we send that data over to the client, and let the client decide if it should be adding CSS and JS on an AJAX request.
Trying to do this sort of AJAX loading is very cool mind you, just this belongs on the client, not the server.
Comment | File | Size | Author |
---|---|---|---|
#2 | ctools-815164-css-js-loading-client-side.patch | 7.6 KB | DeFr |
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedI'm actually generally in favor of this, but I think the issue is that we were having trouble figuring out how to communicate this data. I would welcome a patch that does this, becuase honestly I don't like exploding the cache with this data and I think it should be embedded as a .js command in the footer or something.
Comment #2
DeFr CreditAttribution: DeFr commentedThere you go.
Attached patch adds some CTools settings to the page footer to keep track of the loaded CSS / JS files, and fills the Drupal.CTools.AJAX.{scripts,css} variables with them in the behaviors. This allows to get rid of the fragile server side caching.
Tested with both JS and CSS aggregation on, seems to work fine.
Comment #3
merlinofchaos CreditAttribution: merlinofchaos commentedI am ecstatic that you got this working. This is committed and I'm recommending that core use the same technique in D7.
Comment #4
Scott Reynolds CreditAttribution: Scott Reynolds commentedAhh this is so much better :-D
but I think this is an erroredit:I was wrong no error there.
Comment #6
kcathebat CreditAttribution: kcathebat commentedSorry, new to drupal, I was just wondering how do I install this patch?
Thanks
Kraig
Comment #7
DeFr CreditAttribution: DeFr commented@kcathebat: This patch has been already included in CTools, so you just have to use a version that has been released after July 5, 2010, which means CTools >= 6.x-1.7