Support » Plugin: jQuery Colorbox » [Plugin: jQuery Colorbox] Deregister and consolidate scripts

  • Resolved aaclayton


    Hey techotronic, first off, thanks for this awesome plugin.

    I have one request which you might be able to help me with. I would really like to fold the included jquery/js/css into my own theme files so I can minify the whole thing to eliminate unnecessary calls in my header.

    Unfortunately your colorbox plugin seems to be immune to my usual methods for deregistering a plugin script. Here’s what I’ve been trying.

    add_action( 'wp_print_scripts', 'remove_colorbox_scripts', 100 );
    function remove_colorbox_scripts() {
        wp_deregister_script( ' jquery ' );
        wp_deregister_script( ' colorbox ' );
        wp_deregister_script( ' colorbox-wrapper ' );

    I’ve tried some variations of this approach, but can’t seem to get it to take. Any suggestions for correcting my method?

    Thanks again for the great plugin.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author techotronic


    no idea, I just use wp_enqueue_script () to register and load the scripts for the plugin.

    Why don’t you use the “W3 Total Cache” plugin to minify CSS and JS?
    It works fine on all WordPress sites that I maintain…


    I am trying to do the same thing, but I can not deregister colorbox css. @aaclayton if you find a solution, please share it with me.



    It’s not a solution I’m proud of, but my initial fix was to hack the plugin core and remove the script and style registration.

    Arne, I agree that W3TC is a great utility, I use it myself. However, automatic consolidation and minification isn’t a perfect substitute to having only one CSS and one JS file enqueued in the first place.

    I had forgotten about this issue, in retrospect, I think my problem was I was attempting to wp_deregister_script() when I should have been using wp_dequeue_script().

    I’m at work atm, so I can’t try this now…but:

    wp_dequeue_script( ‘jquery’ );
    wp_dequeue_scropt( ‘colorbox-wrapper’ );
    wp_dequeue_script( ‘colorbox’ );

    should knock out the JS enqueues, while:

    wp_dequeue_style( ‘colorbox-[theme]’ );

    should kill off the css, you’ll need to replace [theme] with the correct handle for the colorbox theme you have selected in plugin options.

    Mladen, let me know if this gives you any luck.

    Thank you for help and fast reply. I made it 🙂
    This is what i did:
    1. Add this code to functions.php . I am using Colorbox theme 9.

    add_action( 'wp_print_styles', 'my_deregister_styles', 100 );
    function my_deregister_styles() {
    wp_deregister_style( 'colorbox-theme9' );

    2. After that i have made some changes to jquery-colorbox-frontend.php on lines 287 and 288. I have replaced colorboxTheme with theme9 on three places.

    At this moment Colorbox CSS is deregistered and images are still opening, but they are ugly and have no functions.

    3. Then I copy theme9 CSS code from wp-content/plugins/jquery-colorbox/themes/theme9/colorbox.css to my main style.css

    Now colorbox opens the images, but there are no buttons. Still everything is working, by pressing left and right you can navigate in gallery. This is because the paths to images are messed in style.css. To fix this you need to:

    4. Copy the images from wp-content/plugins/jquery-colorbox/themes/theme9/images to your themes directory image folder. Or to change the paths in Colorboxs css part in your main style.css.

    And that`s it. Colorbox is working again and even faster. 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: jQuery Colorbox] Deregister and consolidate scripts’ is closed to new replies.