I have searched all over the internet for an answer, please I need someone to help me. I am writing a plugin and I am loading an external Javascript/jQuery file that uses the $ as usual.

We all know that WordPress jQuery file is in no conflict mode. Here are the options I found but none of them seems to work in my case:


 jQuery(document).ready(function($) {


Problem: This only applies to custom script you write. What if you are loading external file

  1. Add this before wp_head()

    var $ = jQuery.noConflict();

Problem: I am writing a plugin, not theme. I am not in control of that

  1. Add this before the external file

    var $ = jQuery; Problem: You may not be able to do this

  • Is there any scope to fix the external file? It would be easy to get them to wrap it in a self-executing function that had argument $ that was passed in jQuery, which would solve this with appropriate scope (at least depending on how that script exports functions)
    – Rup
    Apr 30, 2017 at 8:34

1 Answer 1


You can do this using follow snippet

// Add scripts to wp_head()
function child_theme_head_script() { ?>
    <!-- Your HTML/JavaScript goes here -->
<?php }
add_action( 'wp_head', 'child_theme_head_script' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.