wp_register_script was called incorrectly

You need to hook your function into either wp_enqueue_scripts, admin_enqueue_scripts, or init. wp_footer is too late to enqueue scripts; they need to be enqueued before the wp_head() function is called. The fifth argument of the wp_enqueue_scripts() function, when set to true, will load the script in the page footer instead of header. From the Codex: … Read more

Most elegant way to enqueue scripts in function.php with foreach loop

You need to enqueue the scripts as well, not only register them. You can, however, just simply enqueue a script without registering it if you are not going to enqueue it conditionally. I would try something like this: (Untested and requires PHP5.4+) add_action( ‘wp_enqueue_scripts’, enqueue_scripts, 11 ); function enqueue_scripts() { /** * Build an array … Read more

enqueuing React script and hooking its target div fails to load script

I had a similar issue within WordPress a few days ago but it doesn’t really have anything to do with WordPress. Simply put, your code is loading the babel-polyfill library twice somehow. Most commonly it can happen if you’re using the library yourself and on top of that a third-party library is including that too. … Read more

enqueue and localize script in footer

You should be setting it to show in the footer with the register, so your code should look like this: wp_register_script( ‘flowplayer_object’, get_bloginfo( ‘stylesheet_directory’ ) . ‘/_/js/flowplayer/flowplayer-object-creator.js’, array(), // these are your dependencies, if you need jQuery or something, it needs to go in that array false, // set a version if you want true … Read more

wp_register_script multiple identifiers?

To have the JavaScript Libraries not to load since you already created a bundle of them, do the following: Asumming the following, usual enqueue: function the_js() { wp_enqueue_script(‘bundle_js’, get_template_directory_uri() . ‘/js/bundle.js’, array(), false, false); } add_action(‘wp_enqueue_scripts’, ‘the_js’); and lets say you have in your bundle the following libraries (listing the handles): jquery backbone colorpicker bootstrap_js … Read more

Hyphens vs. periods in the script slug in wp_register_script?

Use hyphens only. Take a look at wp-includes/script-loader.php: $scripts->add( ‘scriptaculous-sound’, ‘/wp-in $scripts->add( ‘scriptaculous-controls’, ‘/wp $scripts->add( ‘scriptaculous’, ”, array(‘sc // not used in core, replaced by Jcrop.js $scripts->add( ‘cropper’, ‘/wp-includes/js/cr $scripts->add( ‘jquery’, ‘/wp-includes/js/jqu // full jQuery UI $scripts->add( ‘jquery-ui-core’, ‘/wp-include $scripts->add( ‘jquery-effects-core’, ‘/wp-in $scripts->add( ‘jquery-effects-blind’, ‘/wp-i $scripts->add( ‘jquery-effects-bounce’, ‘/wp- $scripts->add( ‘jquery-effects-clip’, ‘/wp-in $scripts->add( ‘jquery-effects-drop’, ‘/wp-in $scripts->add( … Read more

Enqueue script only when shortcode is used, with WP Plugin Boilerplate

Why it’s not working: You need to use the wp_enqueue_scripts action hook. You’ve used wp_register_script as an action hook, however, there is no action hook named wp_register_script in WordPress core. If this was just a silly mistake, then you already have the answer. Read on if you need more information regarding the topic: Attaching a … Read more

How to dequeue / deregister any theme styles and scripts

The tricky thing is knowing whether or not a particular script or style was enqueued by the theme. Themes and plugins both use the same hooks and functions, so they’re not explicitly labelled in any way as belonging to a specific theme or plugin. This means that the only way to know whether a script … Read more