Hello,
lately I’ve been seeing the following error in pages where the acf_form_head
loads.
Uncaught ReferenceError: wp is not defined
<anonymous> http://localhost/mn/wp-admin/js/color-picker.min.js?ver=5.5:2
<anonymous> http://localhost/mn/wp-admin/js/color-picker.min.js?ver=5.5:2
Despite the question about how to solve the error, it makes me wonder how many unnecessary things are loaded. Can you completely remove the color-picker as an ACF library component?
Also, (hijacking my own thread :D) same question for other ‘heavy’ elements like repeater sortables.
Answering my own question… found a snippet online that resolves the issue – credit to whoever provided it!
add_action( 'wp_print_scripts', 'pp_deregister_javascript', 99 );
function pp_deregister_javascript() {
if(!is_admin())
{
wp_dequeue_script('wp-color-picker');
wp_deregister_script( 'jquery-ui-datepicker' );
wp_deregister_script( 'wp-color-picker-js-extra' );
wp_deregister_script( 'wp-color-picker' );
}
}