Here is my code:

  Plugin Name: Awesome Form Validation
  Plugin URI: http://itexpertbd.com
  Description: Use 'required' class to enable an input as required.
  Version: 1.0
  Author: Abdus Sattar Bhuiyan
  Author URI: www.facebook.com/abdus.s.bhuiyan
    function awesome_form_validation_scripts() {
       // wp_enqueue_style( 'awesome_form_validation', get_stylesheet_uri() );
        wp_enqueue_script( 'awesome_form_validation', plugin_dir_url( __FILE__ ). '/js/form_validation.js', array(), '1.0.0', true );
    add_action( 'wp_enqueue_scripts', 'awesome_form_validation_scripts' );

Its pretty simple. But after activating plugin I can't see the awesome_form_validation inspecting view page source. Whats wrong with my code?

  • The URL returned from plugin_dir_url contains a trailing slash, are you sure the URL to your file is correct?
    – Milo
    Commented Feb 24, 2018 at 16:50
  • YES. i checked again, location of js:awesome_form_validation/ js/form_validation.js Commented Feb 24, 2018 at 16:53
  • Your code otherwise works fine. Does your theme call the wp_footer() function to output the script?
    – Milo
    Commented Feb 24, 2018 at 17:24

1 Answer 1


plugin_dir_url( __FILE__ ) returns plugin URL with a trailing slash (/). So you have to remove the extra trailing slash.

wp_enqueue_script( 'awesome_form_validation', plugin_dir_url( __FILE__ ). 'js/form_validation.js', array(), '1.0.0', true );

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.