Add jQuery script to WordPress

jQuery is built into WordPress and you can add a jQuery script to your self hosted WordPress website using the built in wp_enqueue_script() function.

  1. Create a simple jQuery js file and call it ‘test.js’.
  2. Save the js file in your WordPress, theme’s ‘js’ folder on your server.
  3. Modify the ‘functions.php’ file in the root directory of your WordPress website to include this line of code: wp_enqueue_script( ‘test’, get_template_directory_uri() . ‘/assets/javascripts/test.js’, array(), ‘1.0.0’, true);

Test refresh your website and the alert popup should appear.


Published by

angelo bonavera

Hi I'm a web developer and I run a web hosting company called

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s