Links a script file to the generated page at the right time according to the script dependencies, if the script has not been already included and if all the dependencies have been registered. You could either link a script with a handle previously registered using the wp_register_script() function, ...

learn more… | top users | synonyms

3
votes
1answer
491 views

How to combine multiple CSS files and concatenate JavaScripts if WordPress recommends enqueuing them?

How would I go about combining multiple CSS files and concatenating my scripts if they're being enqueued as WordPress recommends? My site is pretty slow and would like to optimize for performance.
3
votes
2answers
2k views

Is this a bad implementation of wp_enqueue_script for conditional usage?

Conditionally Including scripts whether js or css in xhtml document head...has been a generally tricky affair, especially if you want to enqueue something, based on a shortcode or custom meta field or ...
2
votes
2answers
901 views

Wordpress Enqueue Script Chaos (jQuery & Foundation.js)

I've been working on building a theme for the past couple days now, and I've run into a wall. While I originally included foundation.js as an enqueued script, I couldn't remember why I had added it. ...
2
votes
2answers
2k views

wp enqueue style on specific page templates

I am in the process of a theme, I would like to add landing pages using page-templates. I cannot find anywhere that shows how to enqueue style or js for specific page templates. Any suggestions. Ex. ...
2
votes
6answers
813 views

WP script versioning breaks cross-site caching?

I am loading JQuery from the google CDN using the following code: wp_deregister_script('jquery'); wp_register_script( 'jquery', // handle - WP uses this name to refer to script ...
2
votes
4answers
3k views

How wp_enqueue_script works?

I am trying to get scripts via wp_enqueue_script();. I have tried this in header but WordPress is not importing any script. I am using like this wp_enqueue_script('jquery'); ...
2
votes
1answer
1k views

How do I implement the Wordpress Iris picker into my plugin on the front-end?

This question here is asking the same question as I am, but there were no adequate answers nor a selected correct answer so I am asking again hoping if I ask in a more coherent manner I might get a ...
2
votes
3answers
1k views

Enqueue script only for IE

I want to use dd belatedpng so the PNG's on my website appear properly on IE. The script I've always used on non-wordpress websites was <!--[if lt IE 7 ]> <script ...
2
votes
3answers
1k views

How can I remove the site URL from enqueued scripts and styles?

I'm dealing with an SSL issue and I would like to strip the domain from all scripts and styles being output via wp_enqueue_scripts. This would result in all scripts and styles being displayed with a ...
2
votes
1answer
883 views

Problem using is_single() to enqueue script from functions.php

I'm having trouble only adding scripts to single post pages. I need to both include and exclude certain scripts using is_single() but it doesn't work either way I try it. I have the template tag on ...
2
votes
1answer
1k views

Wordpress Enqueue for homepage only, functions.php, wp-framework

I'd like to replace my: if(is_home()) { wp_enqueue_script( 'homestuff', get_theme_part( THEME_JS . '/home.js' ), array( 'jquery' ), null, true ); wp_enqueue_script( ...
2
votes
1answer
177 views

Adding Scripts in the Admin Area

I'd like to enqueue scripts only for an admin page that I've created. There's an example of this here: ...
2
votes
3answers
1k views

How do I activate jQuery/script on demand?

I am trying to use jQuery to display the comment-section of my Wordpress-pages, but without requiring that jQuery be present on all pages that allows comments. Basically, I need the following: A ...
2
votes
3answers
521 views

wp_enqueue_script + how to load JS or CSS in one URL merge call?

Is there any proper wordpress way of including the JS and CSS through one merged URL? So that instead of loading in x number of separate calls for each JS asset, it can be all merged into one URL? ...
2
votes
2answers
132 views

How to echo JS right after enqueued script to put it into noConflict mode?

I want to include and use third party JavaScript file (Bootstrap Tooltip) in my plugin. Since Bootstrap is highly popular framework and tooltip() is rather generic name I want to make use of included ...
2
votes
1answer
460 views

Protocol neutral URLS with wp_enqueue_script (SSL issues)?

How do I use wp_enqueue_script so that I get protocol neutral URLs? Here is how I'm currently using it: <?php wp_enqueue_script('name', get_bloginfo('template_directory'). '/js/name.pack.js'); ...
2
votes
1answer
245 views

Add script to footer - on post editor

How do you add a script on the footer of the post editor ? I'm adding a meta box under the post editor and I need to include a javascript before the closing body tag (on the footer) How do I achieve ...
2
votes
1answer
336 views

How do I enqueue(or delay loading of) <script> tags in individual page posts?

My customer has many pages with <script> elements including javascript. <script src="myscriptforthispageonly.js"></script> I'm trying to get all scripts to load in the footer ...
2
votes
1answer
363 views

WP_enqueue_script inside shortcode?

I've got shortcode that needs to include JS library only once and only there where it's used. function shortcode_function($atts, $content = null) { $class = shortcode_atts( array('something' ...
2
votes
2answers
364 views

How to move style from template file to <head> section?

Imagine the following situation: //header.php contains: <header id="header">logo and navigation</header> //my-template.php contains: <?php get_header(); ?> <style ...
2
votes
1answer
580 views

enqueue and localize script in footer

I have a script which must run in my footer, after some variables are declared. It works if I just put the code directly in my footer file, but I think best practices dictate I should do this via ...
2
votes
1answer
592 views

Enqueuing Script in functions.php vs on the page

Does it matter if I enqueue a script on just the page I need it to be used? As opposed to functions.php? Or, what is the best practice? In this example I need a rotator just on the front page of my ...
2
votes
2answers
158 views

Inserting JS snippet in the footer if there is no wp_footer?

I wrote a plugin which uses wp_enqueue_script() which will include the snippet in either the header or footer depending on the parameters you pass it. The in_footer parameter works great - if the ...
2
votes
4answers
2k views

Asynchronous Javascript Loaders

I'd like to take advantage of loading my scripts while the page is loading. ie. Yepnope, head.js etc... But I also want to be able to enqueue the script so other plugins don't try adding their own. ...
2
votes
1answer
454 views

wp_enqueue_script : how to change loading order of scripts?

I would like to know how to list all scripts loaded on a page, ranked by order and change this order.
2
votes
2answers
591 views

Enqueue script in specific page

I am building a wordpress theme with a theme dashboard with options, but as I read somewhere, the enqueue script code I am using just enqueues it in the backend but it loads in every page in the ...
2
votes
3answers
124 views

How to detect if a function has been fired on any page so scripts/styles can be loaded conditionally

I'm building a small gallery plugin and I'd like to only load scripts/styles onto the page IF the gallery has been loaded via the template tag. The template tag can take a post ID parameter when used ...
2
votes
1answer
173 views

Using get_option() in JavaScript

Previously, I used the get_option() function to get an option in PHP, like this: $width = get_option('my_width'); This is inside a shortcode function. Now, I want to have an option in JavaScript. ...
2
votes
2answers
1k views

wp_enqueue_script vs. wp_register_script

Trying to do the right thing here, and tying myself in a knot! So, in my header.php before wp_admin, I have: wp_enqueue_script('commonfunctions', child_template_directory . ...
2
votes
1answer
91 views

Performance-wise, is it better to enqueue a (small) script on every page or test to see if it's needed?

I'm using the FitVids.js script to make YouTube video embeds work with a responsive layout. The script is < 3kb, but only about half of my pages actually have YouTube embeds. In terms of total ...
2
votes
2answers
744 views

Adding Custom Javascript to Skeleton Child Theme

I'm trying to register & enqueue ImageMapster in my Skeleton Child Theme on the main.php page to make an image map with hovering image effects. I added this code to the "Header Functions" section ...
2
votes
2answers
569 views

Is it possible to enqueue a script from a widget method (of extended WP_Widget object)?

I am creating a widget plugin that a user could potentially use multiple iterations of the widget multiple times on a single widget-area / multiple widget-areas on a single page. Because of its ...
2
votes
1answer
1k views

require.js to load javascript

whilst wp_enqueue_script seems to work it's not really elegant. I'm currently making a WP front end which uses MVC (backbone.js) and has literally 30+ seperate Model/View/Collection/Controller scripts ...
2
votes
1answer
977 views

How to use wp_enqueue_style() and wp_enqueue_script() only when needed?

My plugin uses wp_enqueue_style() and wp_enqueue_script() to load resources, but I have kept in mind not to degrade the performance for the user and only load these when the current set of posts ...
2
votes
0answers
107 views

Continue javascript execution when errors occurs [duplicate]

I use the WP native function wp_enqueue_script() for all my JavaScripts loading both in WP front and back-end so it can handle duplicated calls to the same script and so on. One of the issues is that ...
2
votes
0answers
147 views

Multisite plugin development and wp_enqueue_script

I have a plugin I'm developing. It works fine on a single site version of WordPress. It installs on a multisite version of WordPress, it appears to work on the admin pages, but when the plugin ...
2
votes
1answer
2k views

wp_enqueue_script order - external vs inline js

I have a few scripts loading with my theme: // loading script.js <script type="text/javascript" src="script.js"></script> // doing something using script.js <script ...
1
vote
2answers
391 views

Load multiple Javascript scripts

I have three Javascript script that I need to load - imagesLoaded.js lazyload-1.8.4.js and cd.js cd.js contains my functions that use imagesLoaded.js and lazyload-1.8.4.js. Do load them ...
1
vote
2answers
5k views

wp_ajax() question.. not using wp_enqueue_script?

hey guys, weird situation... I'm trying to use wp_ajax() for the first time. I'm normally using a normal jQuery ajax request but in my current case I get a lot of bugs so I thought about trying ...
1
vote
1answer
1k views

How do I get the $handle for all enqueued scripts?

Is there some way to get the $handle for each script that has been enqueued? Is there some array that holds all the handles so that I can loop through it and do something using each $handle?
1
vote
2answers
41 views

When using wp_enqueue_script(); in a theme why don't we use add_action?

When using wp_enqueue_script in a plugin, I have always been told to use an add_action : function add_my_css_and_my_js_files(){ wp_enqueue_script('jquery-validate-min', ...
1
vote
2answers
1k views

How to load JQuery easing script in wordpress?

Ok, first of all, I know how to do this manually. I could just download easing, place it in my plugin folder and load it using wp_enqueue_script. However, I want to load my script in a long-term way, ...
1
vote
1answer
2k views

How do I make script load after jquery?

function load_my_script(){ wp_register_script( 'my_script', get_template_directory_uri() . '/js/myscript.js', 'jquery' ); wp_enqueue_script( 'my_script', 'jquery'); } add_action('wp_enqueue_scripts', ...
1
vote
1answer
1k views

Why is jquery-ui-core enqueueing in my footer instead of the header?

This is what I'm using to make sure that I have jquery-ui-core available: if (!is_admin()) add_action('wp_enqueue_scripts', 'zg_load_scripts'); function zg_load_scripts(){ ...
1
vote
2answers
126 views

enqueue script only if it is not already enqueue

I want to include a script in a shortcode output, so I am trying this: function my_shortcode( $atts, $content = null ) { extract(shortcode_atts(array( 'title' => '', ), ...
1
vote
2answers
2k views

Enqueue jQuery in WordPress

Building my first theme from scratch in Wordpress 3.4.1, I know Wordpress already has the latest version of the JQuery via Google. I have read about issue's if the script is not called properly, so ...
1
vote
1answer
277 views

wp_enqueue_script isn't connecting my custom js file

I am using wp_enqeue_script to link to a custom.js file in my plugins folder. However I am expecting a link to show up on the page but it doesn't is there something else I am supposed to other than ...
1
vote
2answers
84 views

Same Conditionals Not Working on Two Different Hooks

Everyone! I am new to WP and trying to build a plugin. I have the following codes working properly: add_filter('the_content', 'say_hello'); function say_hello($content){ if(is_single() || ...
1
vote
2answers
677 views

Modernizr check first, then move on to wp_register_script()/wp_enqueue_script

I've been playing with Modernizr in WordPress lately and here's something that i'm trying to achive. I'm adding an HTML5 input field in a custom options page, specifically: <input type="number" ...
1
vote
1answer
132 views

How to run a external JavaScript file on wp-admin if admin, and other if normal user?

I'm new to WordPress plugins, and I'm trying to load a external JS/jQuery file with some scripts I need. It needs to run in the wp-admin page (not just once when activated). There is a JS file for a ...