0

According to Wordpress: https://codex.wordpress.org/Javascript_Reference/ThickBox

WordPress makes use of a modified version of the ThickBox jQuery library originally created by Cody Lindley.

ThickBox powers the modal lightboxes used in the WordPress admin, including the post editor's "Media" button (prior to WordPress 3.5 only) and the "Details" links on the Plugin "Search Results" screen.

So if this thing is for the Wordpress admin dashboard, then why does it load on the frontend of my website, even when I'm not logged into the dashboard?

Is it possible to turn it off? I would rather not unnecessarily load JavaScript resources that are not used.

1

You are perfectly right, ThickBox is old and it supposes to be present in admin Dashboard only, but beeing able to change this kind of behavior makes WordPress great (and sometimes not).

Every theme or plugin can actually call this library for his help with the

wp_enqueue_script('thickbox') function or it can use it as a dependency like this:

wp_enqueue_script( 'my_own_modal' , _URL_TO_FILE_, array('thickbox') );

The third parameter works like a dependency array, and every library there is loaded. Sometimes developers miss-enqueue it by mistake in front-end too, or intentionally when a plugin creates an image uploader in front-end.

Solution?

Well, you can try to disable every plugin and see which one does this or you can search all the wp-content folder for the thickbox key and see where it is called.

If you cannot find it you can try to force its removal with the wp_deregister_script

<?php
function my_de_scripts_method() {
    wp_deregister_script('thickbox');
}    

add_action('wp_enqueue_scripts', 'my_de_scripts_method', 9999);
?>

If this still doesn't work(it could be called late or on another hook) you can take the dirty way, register the thickbox before WordPress does with and empty path, and it will be ignored.

<?php
function my_over_register_scripts_method() {
    wp_register_script( 'thickbox', '' );
}    

add_action('wp_enqueue_scripts', 'my_over_register_scripts_method', 1);
?>

Edit: If you want to remove it only in front-end just use the is_admin conditional

<?php
function my_de_scripts_method() {
    if ( ! is_admin() ) {
        wp_deregister_script('thickbox');
    }
}    

add_action('wp_enqueue_scripts', 'my_de_scripts_method', 9999);
?>
| improve this answer | |
  • I ended up doing the deregister thing. But I'm not sure if that means Thickbox now is not loaded in the admin dashboard as well... – Jake Wilson Aug 31 '16 at 5:41
  • Thickbox was used before 3.5 for the media modal. But now this library is almost deprecated, and the WordPress core doesn't use it anymore, only old plugins still need it. – Andrei Aug 31 '16 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.