0

I am adding a javascript file through the functions.php file. I am using the method as suggested on Wordpress Codex. One question I have is that what is the best way to handle the version number column. Is it recommended to send the version of jquery or the version of the script I am loading? Using this code.

<?php
function my_scripts_method() {
// register your script location, dependencies and version
   wp_register_script('custom_script',
   get_template_directory_uri() . '/js/custom_script.js',
   array('jquery'),
   '1.0' );
 // enqueue the script
  wp_enqueue_script('custom_script');
  }
add_action('wp_enqueue_scripts', 'my_scripts_method');
?>
0

The version is the version of your own script, and is appended to the filename in the src attribute of the script tag. This is so you can employ long-term caching on the client-side and still insure a new version of your script will be fetched from the server rather than local cache if you update it.

  • Just what I neded – viyyer Jan 4 '12 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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