Function Reference/wp register script
Languages:
English •
한국어 •
(Add your language)
Description
A safe way of registring javascripts in WordPress for later use with wp_enqueue_script().
Usage
<?php wp_register_script( $handle, $src, $deps, $ver, $in_footer ); ?>
Use the wp_enqueue_scripts action to call this function, or admin_enqueue_scripts to call it on the admin side. Calling it outside of an action can lead to problems. See #11526 for details.
Parameters
- $handle
- (string) (required) Name of the script. Should be unique as it is used as a handle for later use with
wp_enqueue_script().
- Default: None
- $src
- (string) (optional) URL to the script. Example: "http://example.com/wp-includes/js/scriptaculous/scriptaculous.js". This parameter is only required when WordPress does not already know about this script. You should never hardcode URLs to local scripts, use Function Reference/plugins_url (for Plugins) and Function Reference/get_template_directory_uri (for Themes) to get a proper URL.
- Default: None
- $deps
- (array) (optional) Array of handles of any script that this script depends on; scripts that must be loaded before this script. false if there are no dependencies. This parameter is only required when WordPress does not already know about this script.
- Default: array()
- $ver
- (string) (optional) String specifying the script version number, if it has one. Defaults to false. This parameter is used to ensure that the correct version is sent to the client regardless of caching, and so should be included if a version number is available and makes sense for the script.
- Default: false
- $in_footer
- (boolean) (optional) Normally scripts are placed in the <head> section. If this parameter is true the script is placed at the bottom of the <body>. This requires the theme to have the wp_footer() hook in the appropriate place. Note that you have to enqueue your script before
wp_head is run, even if it will be placed in the footer. (New in WordPress 2.8)
- Default: false
Return Values
- (void)
- This function does not return a value.
Notes
- See WP_Scripts::add_data(), WP_Scripts::enqueue()
- Uses global: (unknown type) $wp_scripts
List of $deps values and their script paths that can called for included scripts as of WP 3.3
- utils: /wp-admin/js/utils.js
- common : /wp-admin/js/common.js
- sack : /wp-includes/js/tw-sack.js
- quicktags : /wp-includes/js/quicktags.js
- colorpicker : /wp-includes/js/colorpicker.js
- editor : /wp-admin/js/editor.js
- wp-fullscreen : /wp-admin/js/wp-fullscreen.js
- prototype : /wp-includes/js/prototype.js
- wp-ajax-response : /wp-includes/js/wp-ajax-response.js
- wp-pointer :/wp-includes/js/wp-pointer.js
- autosave : /wp-includes/js/autosave.js
- wp-lists : /wp-includes/js/wp-lists.js
- scriptaculous-root : /wp-includes/js/scriptaculous/wp-scriptaculous.js
- scriptaculous-builder : /wp-includes/js/scriptaculous/builder.js
- scriptaculous-dragdrop : /wp-includes/js/scriptaculous/dragdrop.js
- scriptaculous-effects : /wp-includes/js/scriptaculous/effects.js
- scriptaculous-slider : /wp-includes/js/scriptaculous/slider.js
- scriptaculous-sound : /wp-includes/js/scriptaculous/sound.js
- scriptaculous-controls : /wp-includes/js/scriptaculous/controls.js
- scriptaculous : scriptaculous-dragdrop,scriptaculous-slider,scriptaculous-controls,scriptaculous-root
- cropper : /wp-includes/js/crop/cropper.js
- jquery : /wp-includes/js/jquery/jquery.js , vers 1.6.4
- jquery-ui-core : /wp-includes/js/jquery/ui/jquery.ui.core.min.js
- jquery-effects-core : /wp-includes/js/jquery/ui/jquery.effects.core.min.js
- jquery-effects-blind : /wp-includes/js/jquery/ui/jquery.effects.blind.min.js
- jquery-effects-bounce : /wp-includes/js/jquery/ui/jquery.effects.bounce.min.js
- jquery-effects-clip : /wp-includes/js/jquery/ui/jquery.effects.clip.min.js
- jquery-effects-drop : /wp-includes/js/jquery/ui/jquery.effects.drop.min.js
- jquery-effects-explode : /wp-includes/js/jquery/ui/jquery.effects.explode.min.js
- jquery-effects-fade : /wp-includes/js/jquery/ui/jquery.effects.fade.min.js
- jquery-effects-fold : /wp-includes/js/jquery/ui/jquery.effects.fold.min.js
- jquery-effects-highlight : /wp-includes/js/jquery/ui/jquery.effects.highlight.min.js
- jquery-effects-pulsate : /wp-includes/js/jquery/ui/jquery.effects.pulsate.min.js
- jquery-effects-scale : /wp-includes/js/jquery/ui/jquery.effects.scale.min.js
- jquery-effects-shake : /wp-includes/js/jquery/ui/jquery.effects.shake.min.js
- jquery-effects-slide : /wp-includes/js/jquery/ui/jquery.effects.slide.min.js
- jquery-effects-transfer : /wp-includes/js/jquery/ui/jquery.effects.transfer.min.js
- jquery-ui-accordion : /wp-includes/js/jquery/ui/jquery.ui.accordion.min.js
- jquery-ui-autocomplete : /wp-includes/js/jquery/ui/jquery.ui.autocomplete.min.js
- jquery-ui-button : /wp-includes/js/jquery/ui/jquery.ui.button.min.js
- jquery-ui-datepicker : /wp-includes/js/jquery/ui/jquery.ui.datepicker.min.js
- jquery-ui-dialog : /wp-includes/js/jquery/ui/jquery.ui.dialog.min.js
- jquery-ui-draggable : /wp-includes/js/jquery/ui/jquery.ui.draggable.min.js
- jquery-ui-droppable : /wp-includes/js/jquery/ui/jquery.ui.droppable.min.js
- jquery-ui-mouse : /wp-includes/js/jquery/ui/jquery.ui.mouse.min.js
- jquery-ui-position : /wp-includes/js/jquery/ui/jquery.ui.position.min.js
- jquery-ui-progressbar : /wp-includes/js/jquery/ui/jquery.ui.progressbar.min.js
- jquery-ui-resizable : /wp-includes/js/jquery/ui/jquery.ui.resizable.min.js
- jquery-ui-selectable : /wp-includes/js/jquery/ui/jquery.ui.selectable.min.js
- jquery-ui-slider : /wp-includes/js/jquery/ui/jquery.ui.slider.min.js
- jquery-ui-sortable : /wp-includes/js/jquery/ui/jquery.ui.sortable.min.js
- jquery-ui-tabs : /wp-includes/js/jquery/ui/jquery.ui.tabs.min.js
- jquery-ui-widget : /wp-includes/js/jquery/ui/jquery.ui.widget.min.js
- jquery-form : /wp-includes/js/jquery/jquery.form.js
- jquery-color : /wp-includes/js/jquery/jquery.color.js
- jquery-query : /wp-includes/js/jquery/jquery.query.js
- jquery-serialize-object : /wp-includes/js/jquery/jquery.serialize-object.js
- jquery-hotkeys : /wp-includes/js/jquery/jquery.hotkeys.js
- jquery-table-hotkeys : /wp-includes/js/jquery/jquery.table-hotkeys.js
- suggest : /wp-includes/js/jquery/suggest.js
- schedule : /wp-includes/js/jquery/jquery.schedule.js
- thickbox : /wp-includes/js/thickbox/thickbox.js
- jcrop : /wp-includes/js/jcrop/jquery.Jcrop.js
- swfobject : /wp-includes/js/swfobject.js
- plupload : /wp-includes/js/plupload/plupload.js
- plupload-html5 : wp-includes/js/plupload/plupload.html5.js
- plupload-flash : /wp-includes/js/plupload/plupload.flash.js"
- plupload-silverlight : /wp-includes/js/plupload/plupload.silverlight.js
- plupload-html4 : /wp-includes/js/plupload/plupload.html4.js
- plupload-full : plupload, plupload-html5, plupload-flash, plupload-silverlight, plupload-html4
- plupload-handlers : /wp-includes/js/plupload/handlers.js
- swfupload : /wp-includes/js/swfupload/swfupload.js
- swfupload-swfobject : /wp-includes/js/swfupload/plugins/swfupload.swfobject.js
- swfupload-queue : /wp-includes/js/swfupload/plugins/swfupload.queue.js
- swfupload-speed : /wp-includes/js/swfupload/plugins/swfupload.speed.js
- swfupload-all : /wp-includes/js/swfupload/swfupload-all.js
- swfupload-handlers : /wp-includes/js/swfupload/handlers.js
- comment-reply : /wp-includes/js/comment-reply.js
- json2 : /wp-includes/js/json2.js
- imgareaselect : /wp-includes/js/imgareaselect/jquery.imgareaselect.js
- password-strength-meter : /wp-admin/js/password-strength-meter.js
- user-profile : /wp-admin/js/user-profile.js
- admin-bar : /wp-includes/js/admin-bar.js
- wplink : /wp-includes/js/wplink.js
- wpdialogs : /wp-includes/js/tinymce/plugins/wpdialogs/js/wpdialog.js
- wpdialogs-popup : /wp-includes/js/tinymce/plugins/wpdialogs/js/popup.js
- word-count : /wp-admin/js/word-count.js
- media-upload :/wp-admin/js/media-upload.js
Change Log
- Since: 2.6 (BackPress version: r16)
Source File
wp_register_script() is located in wp-includes/functions.wp-scripts.php.
Related
wp_register_script(), wp_deregister_script(), wp_enqueue_script(), wp_dequeue_script()