Modify registered script dependencies on WordPress

/**
 * Remove all the dependencies of a registered script
 */
add_action(
  'wp_enqueue_scripts',
  function () {
    global $wp_scripts;
    $registered_script_slug = "<registered_script_slug>";
    if (false === $wp_scripts->queue || !isset($wp_scripts->registered[$registered_script_slug]->deps)) {
      return;
    }
    $wp_scripts->registered[$registered_script_slug]->deps = array();
  },
  101
);
Code language: PHP (php)

Posted

in

,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.