wp_dequeue_script()删除预计加载的脚本

目录

描述

Remove an enqueued script.

To be dequeued, the script must have been enqueued. Attempting to dequeue a script before the script is enqueued will have no effect.

wp_dequeue_script() 描述

用法

<?php wp_dequeue_script$handle ); ?>

wp_dequeue_script() 用法

参数

$handle

(string) (必填) The slug of the script to dequeue

默认值: None

wp_dequeue_script() 参数

示例

Dequeue a script.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */

/**
 * Dequeue the jQuery UI script.
 *
 * Hooked to the wp_print_scripts action, with a late priority (100),
 * so that it is after the script was enqueued.
 */
function wpdocs_dequeue_script() {
   wp_dequeue_script( 'jquery-ui-core' );
}
add_action( 'wp_print_scripts', 'wpdocs_dequeue_script', 100 );

wp_dequeue_script() 示例

历史

添加于 版本: 3.1

wp_dequeue_script() 历史

源文件

wp_dequeue_script() 函数的代码位于 wp-includes/functions.wp-scripts.php

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Remove a previously enqueued script.
 *
 * @see WP_Dependencies::dequeue()
 *
 * @since 3.1.0
 *
 * @param string $handle Name of the script to be removed.
 */
function wp_dequeue_script( $handle ) {
	_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );

	wp_scripts()->dequeue( $handle );
}

wp_dequeue_script() 源文件

相关