You either use the admin_*/wp_print_scripts
hook or the admin_*/wp_print_styles
hook. The styles hook comes before the print scripts hook, so maybe it fits better than just using a priority of 0
for the *_print_scripts
hook (there might be function with a name that’s hooked in earlier on priority 0
).
function wpse61635_remove_all_scripts()
{
global $wp_scripts;
$leave_alone = array(
// Put the scripts you don't want to remove in here.
);
foreach ( $wp_scripts->queue as $handle )
{
// Here we skip/leave-alone those, that we added above ↑
if ( in_array( $handle, $leave_alone ) )
continue;
$wp_scripts->remove( $handle );
}
}
add_action( 'wp_print_styles', 'wpse61635_remove_all_scripts', 0 );