I've included the javascript by

wp_enqueue_script('slider', plugins_url( 'slider.js', __FILE__ ) );

with just a simple

$(document).ready(function () {

It shows up in the browser but doesn't prompt me with "alert".

PS: Forgot to mention I've also included the jquery, but still not working.

wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", false, null);

In addition to the answers, I also had to tell wordpress that my script depends on jQuery

wp_enqueue_script( 'slider', plugins_url( 'slider.js', __FILE__ ),array('jquery') );

3 Answers 3


A few things:

  1. The version of jQuery that ships with WordPress is run in noConflict() mode. Meaning you have to use jQuery instead of $ when you make your first reference.
  2. Don't register your own version of jQuery when you're developing. You're locking yourself in to a single version that may or may not be compatible with WordPress' other requirements.
  3. You can use the browser console to test things. Open your page, then hit F12 to launch the console. Type jQuery into the console and see whether or not it returns the correct object.

WordPress loads jQuery in "No Conflict" mode. The $ alias does not work. Use jQuery.(document) or wrap your code like...

(function($) { 
  $(function() {
    // more code using $ as alias to jQuery

It is worth to check according to the Bootstrap .js declaration if required (after jQuery) i.e.

<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>

Your Answer

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

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