WordPress.org

Forums

JS & CSS Script Optimizer
Plugin affecting photo galleries/sliders (3 posts)

  1. sergiobarreto
    Member
    Posted 2 years ago #

    Hi, I really like what your plugin does in terms of speed/optimization, but I have one problem: The plugin keeps my homepage slider from working, and it also ruins the Carousel feature in Jetpack. Is there any way to add an exception for these features?

    Thanks in advance!

    http://wordpress.org/extend/plugins/js-css-script-optimizer/

  2. Rick Buczynski
    Member
    Posted 2 years ago #

    Same here. I have a custom slider, but the problem is caused by this:

    Uncaught ReferenceError: thickboxL10n is not defined

    It appears that packing thickbox.js produces undesirable results. Moreover, if I try to exclude it from the scripts via the exclude-js field, then the order in which the scripts are processed is wrong, so I get jQuery undefined errors.

    So is there a way to define a script order that takes into account all scripts (even excluded ones)?

    It would be nice if we could also determine which scripts go to the bottom of the page, and which ones stay in the head.

  3. Rick Buczynski
    Member
    Posted 2 years ago #

    I did more research. It seems that by combining scripts, localization is lost for thickbox.js. In WP 3.5.1, see /wp-includes/script-loader.php, line 182:

    did_action( 'init' ) && $scripts->localize( 'thickbox', 'thickboxL10n', array(
    			'next' => __('Next >'),
    			'prev' => __('< Prev'),
    			'image' => __('Image'),
    			'of' => __('of'),
    			'close' => __('Close'),
    			'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'),
    			'loadingAnimation' => includes_url('js/thickbox/loadingAnimation.gif'),
    			'closeImage' => includes_url('js/thickbox/tb-close.png')
    	) );

    When the plugin is enabled with combining on, this localization is not triggered (hence the thickboxL10n undefined errors).

    I fixed my issue by adding this to my theme's functions.php:

    function mytheme_thickbox_compression_fix() {
        echo '<script type="text/javascript">';
        echo "var thickboxL10n = ".json_encode(array(
            'next' => __('Next >'),
            'prev' => __('< Prev'),
            'image' => __('Image'),
            'of' => __('of'),
            'close' => __('Close'),
            'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'),
            'loadingAnimation' => includes_url('js/thickbox/loadingAnimation.gif'),
            'closeImage' => includes_url('js/thickbox/tb-close.png')));
        echo '</script>';
    }
    add_filter('wp_footer','mytheme_thickbox_compression_fix',20000001);

    It's a hack that works for now, at least until this issue can be addressed by the developer.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • JS & CSS Script Optimizer
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags