wpseek.com
A WordPress-centric search engine for devs and theme authors
wp_enqueue_script › WordPress Function
Since2.1.0
Deprecatedn/a
› wp_enqueue_script ( $handle, $src = '', $deps = array(), $ver = false, $args = array() )
| Parameters: (5) |
|
| See: |
|
| Defined at: |
|
| Codex: | |
| Change Log: |
|
Enqueues a script.
Registers the script if$src provided (does NOT overwrite), and enqueues it.Related Functions: wp_enqueue_scripts, wp_dequeue_script, wp_enqueue_script_module, wp_enqueue_style, wp_dequeue_script_module
Source
function wp_enqueue_script( $handle, $src = '', $deps = array(), $ver = false, $args = array() ) {
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );
$wp_scripts = wp_scripts();
if ( $src || ! empty( $args ) ) {
$_handle = explode( '?', $handle );
if ( ! is_array( $args ) ) {
$args = array(
'in_footer' => (bool) $args,
);
}
if ( $src ) {
$wp_scripts->add( $_handle[0], $src, $deps, $ver );
}
if ( ! empty( $args['in_footer'] ) ) {
$wp_scripts->add_data( $_handle[0], 'group', 1 );
}
if ( ! empty( $args['strategy'] ) ) {
$wp_scripts->add_data( $_handle[0], 'strategy', $args['strategy'] );
}
if ( ! empty( $args['fetchpriority'] ) ) {
$wp_scripts->add_data( $_handle[0], 'fetchpriority', $args['fetchpriority'] );
}
}
$wp_scripts->enqueue( $handle );
}