0
votes

hi , I have some trouble trying to implement a Gallery for each post.

well in fact the problem is not making it work, the problem is that the website slows down like a tourtle.

I use cycle for every gallery:

var  
    id = $('#gallery-id-<?php the_ID(); ?>'),
    container = $('#container'),
        leftArrow = $('#leftArrow'),
        rightArrow = $('#rightArrow')

    id.cycle({
        timeout:0,
        fx:'scrollHorz',
        prev: prv,
        next: nxt,
        easing: 'easeOutExpo' 
    });

But Generating a gallery for 10 post is making the site super slow....

and well cycle is not the only plugin called in a post , it also use , jspScroll, qTip, etc.

what do you recommend to add jquery, in every post , to show content accurate and fast?

thanks

1

1 Answers

0
votes

If you are using a fair amount of jQuery 'plugins' you will definitely notice a dramatic degradation performance. An quick and easy way to help boost performance on less UI intensive pages may be to contextualize your code. For instance, if you only need to have Cycle run on the home page in a Wordpress build you can use an "if" statement:

if($('body').hasClass('home')) {
  var  
    id = $('#gallery-id-<?php the_ID(); ?>'),
    container = $('#container'),
    leftArrow = $('#leftArrow'),
    rightArrow = $('#rightArrow')

  id.cycle({
    timeout:0,
    fx:'scrollHorz',
    prev: prv,
    next: nxt,
    easing: 'easeOutExpo' 
  });
}// End body.home only

All this does is look at the <body> class and checks to see if the page has that class. If it has that class, it will run the necessary jQuery calls. You can start to see how this can easily become a maintenance issue so contextualize appropriately!

p.s. Without seeing the rest of your code, I can say from experience that jspScroll is a confirmed culprit of "slow" sites - especially if you are running it on large DOMs.