Right now you can't cache your block views (at least not through direct block caching, only through views cache), because the libraries will not be included if the block gets fetched from cache.

I would like an option to include the libraries globally no matter whether the current page contains a carousel or not.

Comments

ralf.strobel’s picture

Title: Option to include libraries on every page load. » Compatibility with block caching

I just did another test where I had included the "jcarousel.js" and "jquery.jcarousel.min.js" files manually and it still didn't work. There is obviously something else missing.

It's curious that the rendered output caching of views does not cause any problems.

I'm making the title of this issue a little more general.

slashrsm’s picture

Have you found anything else about this issue?

ralf.strobel’s picture

What do you mean?

slashrsm’s picture

Do you have any at least partly working fix for this?

ralf.strobel’s picture

Sorry, views is one of the modules I have never looked under the hood, so I can't really suggest anything.

If I find the time I will at least try to determine exactly what is missing to cause this error.

slashrsm’s picture

I fixed this with using Vews internal query cache and disabling block cache on this block.

ralf.strobel’s picture

That's what I said in my initial post. I actually find it curious that this works. So what does Views do different than the block cache?

quicksketch’s picture

Unfortunately jCarousel adds per-carousel JS to the page. So the only way you'd be able to add the JS globally would be if you added the JS for all carousels on the entire site to every page on the entire site. This would not only be wasteful but also difficult to figure out where jCarousel was used throughout the site.

I also haven't looked into the Views render cache to see if it's possible to use #attached properties, but from my impression of the render cache, I think that it would be unlikely.

The jcarousel_add() function already returns an array that is suitable for use as an #attached property, but I don't really know where we'd need to modify our code to make this array of properties get passed to the Views render cache (and also the Drupal block cache).

ralf.strobel’s picture

Alright, I've looked into the views render cache a bit and quicksketch is right....

Views currently caches the final HTML output and not the render array, so using #attached is out of the question. BUT, views_plugin_cache is really smart and also stores any js which has been added during the render method. That's why jCarousel works with the views cache in the first place.

Since this solution is actually very performant and the cache time handling of view is a lot better than that of the block system anyway, I think my initial request to support the block cache is no longer relevant.

Still, it remains a problem that the Carousels are broken if someone enables block caching. Is there any way to disable the functionality or should this simply be resolved through documentation?

smilysarat’s picture

Hii I got a problem with jcarousel module, everything is working perfect but except when I first launch the site the initial 6 images shows up ok. But, if i click on the forward/backward to scroll images i get a total "blank" page. One has to click 2/3 times to get remaining images.. Please help me how do i overcome from this issue....

if i press ctrl+f5 this issue occurs again... if i press enter on the url it works perfect.. i am getting little bit confusion on this..

ralf.strobel’s picture

Sounds like you have the ajax loading on and it just takes a while. Anyway, this doesn't belong here. Please open up your own issue!

smilysarat’s picture

thanks for your response, as u suggested i was created an issue..(http://drupal.org/node/1440598) in the meanwhile is there any compatible module for this.. to work on version 7

smilysarat’s picture

Issue summary: View changes

More precise description.

markpavlitski’s picture

Issue summary: View changes
Status: Active » Postponed

I can't see any way to get this working without either views or core changes.

The views issue is here: #1894736: Cannot use #attached to add general CSS/JS/Library to a View and the core issue is here: #1460766: [PP-1] Fix block cache to use Attachment Collectors to prevent brokenness with drupal_add_* calls.

In the meantime disabling block caching or using a module such as Block cache alter to disable block caching for each of the jCarousel blocks should resolve the issue.

You can still use views caching for each of the views/blocks instead which will offer similar performance, as views has a built-in workaround for this issue.

Edit: added issue links.