I'm working on a plugin that relies on several JS scripts. In my plugin file (graph-plugin.php) I've the following function:

function initialize_scripts() {
    wp_register_script( 'int-flot', WP_PLUGIN_URL . '/wp-graph-test/js/init-flot.js', array ( 'jquery' ), NULL, true);
    wp_enqueue_script( 'int-flot' );
    wp_register_script( 'int-dtpck', WP_PLUGIN_URL . '/wp-graph-test/js/init-datepickers.js', array ( 'jquery' ), NULL, true);
    wp_enqueue_script( 'int-dtpck' );
add_action( 'wp_enqueue_scripts', 'initialize_scripts' );   

At the moment my functions should do console log and alert but that is not working.

jQuery(document).ready(function($) {


One script should initialize js-flot and other should initialize ui-datepickers. Do I need to move my initialisation in functions.php file? I can see this scripts in the footer when I check in resources. Thank you!

1 Answer 1


Try to write it like this:

(function($) {$(document).ready(function(){...});})(jQuery);
  • Did you miss closing one pair of parentheses and braces? I've tried with added closing parenthesis and braces but still no luck. Is it better idea to move the script to the function?
    – Moirae
    Dec 8, 2015 at 9:59
  • Unfortunately there is still no result. The code actually works fine when not implemented as a plugin
    – Moirae
    Dec 8, 2015 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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