wp_enqueue_script vs. wp_register_script

I think you should just enqueue the script as well (for your validate script). I would wrap it around one whole function as well to avoid issue #11526: calling out

Thus all together:

<head>
...
<?php 

function mytheme_enqueue_script() {
// Load jQuery
wp_enqueue_script('jquery');
// Load draggable
wp_enqueue_script('jquery-ui-draggable');
//load your script
wp_enqueue_script('commonfunctions', child_template_directory . '/script/commonfunctions.js', array('jquery', 'jquery-ui-draggable'), '1.0', true);
// Load validate
wp_enqueue_script('validate','http://ajax.microsoft.com/ajax/jQuery.Validate/1.6/jQuery.Validate.min.js', array('jquery'), true);
}

add_action('wp_enqueue_script', 'mytheme_enqueue_script');

Sorry, i haven’t tested this yet. So i may be off.

Leave a Comment