• Resolved the_enn

    (@the_enn)


    Hi,

    I have a child theme and want to enqueue a small .js file in the footer.

    It’s being queued properly. However, this script needs to use the parent theme .js file as a dependency and this parent .js is in the footer. The parent .js doesn’t have a handle.

    I tried to register the parent theme to add a handle for reference when enqueuing the child theme .js, but it doesn’t seem to work.

    I can get my child .js to queue in the footer, just not dependent on the parent theme .js in the footer.

    Any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • It should have a handle if it’s being enqeued properly. If you can find out how it’s being added to the theme you can find out what the handle is.

    – – – – –

    Another option is to enqueue your script into the footer and give your wp_enqueue_scripts a very high hook so it runs later:

    add_action( 'wp_enqueue_scripts', 'my_enqueue_function', 999 );

    This may be unreliable though since you do now know how the parent script is being enqueued or what priority it has on it’s action hook.

    – – – – –

    Another option is to hook directly into wp_footer, again at a high priority and manually add in your script with HTML. Again though this option may be unreliable because you do not know how the original script is being enqueued.

    – – – – –

    The most reliable solution is to find the script handle. You can always reach out to the theme developers and get their thoughts on the matter.

    Thread Starter the_enn

    (@the_enn)

    Thanks, Howdy. There’s no handle in the HTML source so I’ll need to get in touch with the theme developer (DIVI).

    • This reply was modified 5 years, 8 months ago by the_enn.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to enqueue footer script dependent on parent js in footer??’ is closed to new replies.