Disable script everywhere except where used – what’s the handle?
-
I am using and embedding a PDF on a single page but
/wp-content/plugins/dearpdf-lite/assets/js/dearpdf-lite.min.js
is loaded on every single page and requiring 180KB in size.I would like to unload it but I need to have the handle for it and this didn’t work out yet.
Can you help me on how to do this?
<?php
function dequeue_dearpdf_lite_script() {
$script_handle = 'dearpdf-lite'; // Ensure this is the correct handle
$required_page_slug = 'pagewithdearpdfused';
if (!is_page($required_page_slug)) {
wp_dequeue_script($script_handle);
}
}
add_action('wp_enqueue_scripts', 'dequeue_dearpdf_lite_script', 100);Is this perhaps something I should even do differently and not how I planned to do it?
Thanks
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.