3 回答

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超9個(gè)贊
Elementor 和 Elementor PRO 注冊(cè)和排隊(duì)一些具有依賴(lài)關(guān)系的腳本。對(duì)于刪除,您需要在沒(méi)有特定腳本的情況下取消注冊(cè)并再次注冊(cè)(例如沒(méi)有“elementor-sticky”)。
if(is_front_page()) {
// Dequeue and deregister elementor-pro-frontend
wp_deregister_script( 'elementor-pro-frontend' );
// Re-register elementor-frontend without the elementor-sticky dependency.
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
wp_register_script(
'elementor-pro-frontend',
ELEMENTOR_PRO_URL . 'assets/js/frontend' . $suffix . '.js',
[
'elementor-frontend-modules',
],
ELEMENTOR_VERSION,
true
);
}
}
add_action( 'wp_enqueue_scripts', 'elementor_pro_frontend_scripts', 20 );

TA貢獻(xiàn)1842條經(jīng)驗(yàn) 獲得超22個(gè)贊
我找到了一個(gè)適合我的解決方案。如果您有更清潔的解決方案,請(qǐng)告訴我:)
if(is_front_page()) {
// Dequeue and deregister elementor-sticky
wp_dequeue_script( 'elementor-sticky' );
wp_deregister_script( 'elementor-sticky' );
// Dequeue and deregister elementor-pro-frontend
wp_dequeue_script( 'elementor-pro-frontend' );
wp_deregister_script( 'elementor-pro-frontend' );
// Re-register elementor-frontend without the elementor-sticky dependency.
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
wp_register_script(
'elementor-pro-frontend',
ELEMENTOR_PRO_URL . 'assets/js/frontend' . $suffix . '.js',
[
'elementor-frontend-modules',
],
ELEMENTOR_VERSION,
true
);
}
}
add_action( 'wp_enqueue_scripts', 'elementor_pro_frontend_scripts' );```

TA貢獻(xiàn)1865條經(jīng)驗(yàn) 獲得超7個(gè)贊
如果您知道正在添加的操作的名稱(chēng),您可以使用該功能,remove_action( $tag, $function_to_remove, $priority )
或者您可以使用wp_dequeue_script( $handle )
https://codex.wordpress.org/Function_Reference/remove_action
https://codex.wordpress.org/Function_Reference/wp_dequeue_script
- 3 回答
- 0 關(guān)注
- 213 瀏覽
添加回答
舉報(bào)