WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I found Morris.js to be a delightfully implemented charting script, and wanted to include it in my Wordpress installation. But I have never included a js file with my blog before, and would appreciate if someone can guide me on this:

  1. How do I include the javascript file?
  2. Where do I upload it on the server?
  3. Anything else I need to know to use it?


share|improve this question
up vote 2 down vote accepted

Create js folder in your theme directory then save Morris.js into it. it is not mandatory to store it in js folder you can store it anywhere else but i recommend to do it to seprate javascipt files from other files.

Add follwing action into functions.php file

function custom_scripts() {
/* Include Scripts */
wp_enqueue_script( 'morris-script', get_template_directory_uri() . '/js/Morris.js', array( 'jquery' ), '', true );
add_action( 'wp_enqueue_scripts', 'custom_scripts' );

You can find more information about wp_enqueue_script() function from this link http://codex.wordpress.org/Function_Reference/wp_enqueue_script of wordpress codex.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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