Bartłomiej Tomaja Bartłomiej Tomaja - 1 year ago 62
jQuery Question

wordpress add own javascript file. no reaction

I add to children template directory in scripts.php code:


function load_styles_and_scripts() {

wp_register_script (

wp_enqueue_script ('myScript');

add_action('wp_enqueue_scripts', 'load_styles_and_scripts');

my script.js file contain:

$( document ).ready(function() {
console.log( "ready!" );
alert("Hello! I am an alert box!");

folders / paths

I set my optional theme in wordpress as active one.
CSS is loading correct but javascript from script.js not - is no making any differences on site.

I fight all day with this.
Thanks straight away ;)

Script is loaded - firebug

Answer Source

To use jQuery with WordPress, you must use the string 'jQuery' instead of '$'. For example:


If you wish to override the jQuery function and use '$', checkout this reference So for your example do something like this:

jQuery(document).ready(function() {
    alert('Hello! I am an alert box!');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download