Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Wordpress hook wp_register_script

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 325
    Comment on it

    Hello Readers,

    Description Description Registers is a script file on WordPress, and is supposed to be linked to a website later with all the wp_enqueue_script() function, which usually safely manages this script dependencies.

    Scripts that were pre-registered by using wp_register_script() do not need to be manually enqueued through use of wp_enqueue_script() when they are usually shown being a dependency of yet another script that is enqueued. WordPress will routinely add the registered script before including this enqueued script so that this registered script copes with being a dependency. Understand the Notices to learn more

    Usage

    wp_register_script( $handle, $src, $deps, $ver, $in_footer );

    So what are these variables and do we need them every time? (This is covered on the Codex page, so I'll give a brief description and not use jargons)

    $handle what you'll use to refer to this particular script when you might need to enqueue it. You have to include this variable at the very least.

    $src Its the path to the source file within your plugin or theme.

    $deps In case of an array containing the $handle for any other scripts, your script needs to run (i.e. a dependency).

    $ver It tell you the version number for your script, which can be used for cache-busting. By default, WordPress will use its own version number as the version number for your script.

    $in_footer do you want your script to load in the footer? Set this to true or false. It is false by default, so it loads in the header where wp_head() is, and if you specify true, it will load where wp_footer() appears in the theme.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: