I'm trying to optimize my header and I was wondering which plugin would call jquery. Is there a debugging tool to know which plugin is doing what in the header ?
Thanks !
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityPlugins and themes tend to use wp_enqueue_script()
to queue up scripts for the <head />
of your theme.
I would rarely advise this, but since you only need to do it temporarily, you could modify WordPress core and run a debug backtrace for every call to this function.
In wp-includes/functions.wp-scripts.php
, drop the following code inside the end of the wp_enqueue_script()
function (starts at line 96).
global $_script_callers_backtrace;
if ( !$_script_callers_backtrace )
$_script_callers_backtrace = array();
$backtrace = debug_backtrace();
$_script_callers_backtrace[] = array( $handle, $backtrace[0]['file'] );
Now pop the following in your theme's functions.php
;
function __save_script_callers()
{
file_put_contents( WP_CONTENT_DIR . '/callers.' . date('d-m-Y-H-i-s') . '.log', print_r( $GLOBALS['_script_callers_backtrace'], true ) );
}
add_action( 'shutdown', '__save_script_callers' );
Now whenever you load a page on your website, a log gets generated in your WordPress wp-content
folder that'll contain a list of the script handlers and the files that triggered them.
Remember! Undo the changes once you've found out what you need!
There is a nifty little function called debug_filters() which lists the callbacks registered on a certain hook.
You would call from your theme, at the end of the header.php file for example:
<?php debug_filters('wp_head'); ?>
wp_enqueue_script()?
Only ones hooked to wp_head
?
Mar 14, 2011 at 10:28