The wp-enqueue-script tag has no wiki summary.
2
votes
1answer
193 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
176 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
389 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
392 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
138 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
43 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
1answer
123 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
877 views
How do I dequeue a parent theme css file?
My parent theme (Starkers) adds a CSS file that I'm trying to remove (I want to use @import instead so I can override styles more easily). Starkers has the following in its functions.php:
add_action( ...
2
votes
1answer
194 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.
2
votes
1answer
68 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
1answer
801 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
743 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
73 views
Continue javascript execution when errors occurs
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
68 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
2answers
365 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
1answer
1k 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
75 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
3answers
524 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 ...
1
vote
2answers
4k 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
228 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
62 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
1answer
757 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
509 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
768 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( ...
1
vote
1answer
58 views
Problem with wp_enqueue_scripts in plugin
I've created the following plugin which requires a js library, however attempts to load the plugin with the line add_action( 'wp_enqueue_scripts', 'calc_script' ); in place fail with the error ...
1
vote
1answer
116 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 ...
1
vote
2answers
103 views
Avoiding Duplicate function names in Post Loop (WP_Footer script)
Say I created a plugin that injects content (used as a shortcode) into a post. I'm trying to push that code for each post to the bottom of the page.
This works fine, however when you are on an ...
1
vote
2answers
1k 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
518 views
force enqueue script to be first in order of prominence
I have a few scripts which are being enqueued,
the problem is that I want to force the order of prominece to which these scripts are loaded. There is one in particular which is loaded from a plugin ...
1
vote
2answers
184 views
Enqueued scripts and styles loading in WordPress Dashboard as well
For a moment, I wondered if my test site got hacked -- my WordPress site's dashboard was all broken (cosmetically). But when i looked at the source code of the page, I noticed that the "scripts and ...
1
vote
1answer
327 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
1answer
148 views
Enqueue script with url_query variables?
Is there an easy way to enqueue a JavaScript file with url_query values populated?
I have a php file underneath my js directory with JavaScript headers that I want to generate some dynamic JavaScript ...
1
vote
1answer
133 views
getting a js file for one page
wp_register_script('SliderViewer', '/js/SliderViewer-1.2.js');
wp_enqueue_script('SliderViewer');
get_header();
however, mydomain.com/js/SliderViewer-1.2.js doesn't exist.
My js is in the ftp at
...
1
vote
3answers
2k views
using wp_enqueue_script to attach jquery-ui
I am trying to load jquery-ui using wp_enqueue_script. I can check that jquery is loaded. jquery-ui is registered i.e. output of var_dump( wp_script_is( 'jquery-ui-tabs', 'registered' ) ); is ...
1
vote
1answer
104 views
wp_enqueue_script & constants?
I'm enqueuing a script:
wp_enqueue_script('my-script', MY_SCRIPTS."/my-script.js");
How to get MY_SCRIPTS const working in this context?
I know this works:
$template_dir = ...
1
vote
1answer
301 views
enqueue the scripts
I have a template that has been hardcoded in the header and it needs to be Enqueued. I don't know what to do and the template provider is giving me the run around. JQueries won't work because of it. I ...
1
vote
2answers
797 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 ...
1
vote
2answers
208 views
How do you enqueue a Visual Basic script using wp_enqueue_script?
Internet Explorer will have errors with VB script files en-queued using wp_enqueue_script. This is probably because the output of enqueue script set the script type to 'language/javascript'. Are ...
1
vote
2answers
41 views
Enqueueing Scripts on a Custom Top-level Menu Page
I've created a menu page using the following function:
add_menu_page(
'Nonpareil options',
'Nonpareil options',
'administrator',
'nonpareil_theme_options',
'nonpareil_theme_display'
);
...
1
vote
1answer
142 views
How do I get my page to load the jQuery UI Effects library?
I'm using javascript for the first time to do some simple animations on the home page of my website. So far I have added the following to my header.php file (which is only used for my home page), ...
1
vote
2answers
108 views
Register and load scripts
In my functions.php
function load_scripts()
{
wp_enqueue_script( 'jquery' );
wp_register_script( 'modernizr', get_template_directory_uri() .'/js/modernizr.foundation.js' );
...
1
vote
1answer
150 views
wp_enqueuescript won't load in footer even with true value set?
Below is my code for enqueue my scripts and css. I am trying to get the JavaScripts to load in the footer of my site, but when I view source I see them loading in the header. I suppose the "true" ...
1
vote
3answers
596 views
How do I force wp_enqueue_scripts to load at the END of <head>?
I am loading scripts via wp_enqueue_scripts in my child theme.
The only problem is that my style.css script get loaded BEFORE plugin scripts, yet I need to override the css in the plugins with my ...
1
vote
1answer
111 views
Is it recommended to pass some data to scripts in `wp_enqueue_scripts`?
I have on many occasions used wp_enqueue_script to pass some 'query variables' to scripts like this:
function my_enqueue_scripts(){
$tempurl = urlencode( get_bloginfo( 'template_url' ) );
...
1
vote
2answers
361 views
Best way to include jQuery and fire with script at bottom of container
I'm going to be using a jQuery slider on my homepage only (not a WP plugin, but a third party). What I'd like to do is include jQuery, the plugin's jQuery script using a .js file, then include the ...
1
vote
2answers
715 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 . ...
1
vote
2answers
625 views
How to control what jQuery version to include, with wp_enqueue_script
I'm using a script that is based on jQuery, so I'm not enqueue-ing jQuery directly, but via passing it in the array of dependent scripts:
...
1
vote
1answer
5k views
How to link external javascript files?
I am working on a custom Wordpress theme for my bosses website. I have everything working perfectly so far except for one thing... the external javascript files will not work.
I followed the exact ...
1
vote
1answer
144 views
Replacing Scripts in Admin Load_Scripts
I'm currently creating a plugin that requires me to overwrite one of the Wordpress admin panel javascript files. I have recreated the file with the changes, I need to know how to replace the existing ...