Support » Plugins » Hacks » Enqueued scripts: inspecting / editing dependencies

  • In my theme at the moment, I have scripts.js dependent on jquery.js and jquery-plugin.js. Now, that’s all fine, and I have those two dependencies listed when I register the script.

    But, on my contact page, I use an additional script: gmap.js. On this page, scripts.js is dependent on this as well. So, at the moment, I do the following :

    if( is_page('contact') ) {
      wp_enqueue_script('scripts.js', 'js/scripts.js', array('jquery','jquery-plugin.js','gmap.js'));

    My question is is there a better way of adding the dependency for just that page?

    Maybe something like $array = get_dependencies('script.js'); and set_dependencies('script.js', $array);.

    Thanks in advance

  • The topic ‘Enqueued scripts: inspecting / editing dependencies’ is closed to new replies.