New answers tagged wp-enqueue-script
0
why not simple use the elementor hooks to unset an asset? like this:
function remove_elementor_swiper() {
wp_dequeue_script( 'swiper' );
wp_deregister_script( 'swiper' );
}
add_action( 'elementor/frontend/after_register_scripts', 'remove_elementor_swiper' );
1
It still displays the script because you are using the wrong hook (and it doesn't exist) — wp_dequeue_scripts, and secondly, if the script is indeed enqueued via wp_enqueue_script(), then the generated id (used in the <script> tag) is in the form of <script handle>-js (i.e. suffixed with a -js) where <script handle> is the first parameter ...
1
The reason this is happening is because the markup that is filtered by script_loader_tag includes the inline scripts. So when you filter it and replace all the HTML tag for a particular script, your filter is removing those inline script tags. If you print out the original value of $tag from within your filter you will see this.
You can look at the source of ...
0
Just replace your add action line to this one: add_action( 'wp_enqueue_scripts', 'my_child_script' ); and check again
0
I am presuming you want to add this as resource hints on the HTML and not as an server push header. As preload is not supported by WP native wp_resource_hints function, you would need to create a custom function printing the preload tags and add somewhere in the beginning of head section of the HTML. Something like the following.
// Adds preload resource ...
Top 50 recent answers are included
Related Tags
wp-enqueue-script × 979javascript × 205
wp-enqueue-style × 185
jquery × 180
plugin-development × 97
wp-register-script × 93
functions × 91
plugins × 67
theme-development × 56
scripts × 55
css × 49
php × 46
child-theme × 42
actions × 33
ajax × 27
wp-localize-script × 27
themes × 25
hooks × 25
shortcode × 22
wp-admin × 21
wp-head × 19
customization × 18
footer × 17
jquery-ui × 16
conditional-tags × 14