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

0
votes
2answers
360 views

enqueue_script doesn't work with HTML5 blank theme

I am trying to enqueue a couple of js files using something like this code: function scripts_function() { wp_register_script('mapbox', 'http://api.tiles.mapbox.com/mapbox.js/v0.6.7/mapbox.js'); ...
0
votes
2answers
84 views

wp_enqueue_scripts hangs

In the following snippet, when I add the wp_enqueue_scripts call, the page freezes. What am I doing wrong? function my_enqueue_stuff() { if ( is_front_page() ) { wp_enqueue_style('style', ...
1
vote
0answers
59 views

How to load script-related styles automatically?

Scenario: It is common that a JS dependency is bundled with a style file to work properly (just think about your favorite slideshow jQuery plugin). AFAIK, in this situation, the script and style have ...
1
vote
1answer
188 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
0answers
141 views

Is it possible to enqueue the Youtube API script or does it have to be inline?

The code below is the main part of a function in my functions.php which returns a div and script which ultimately output a youtube API iframe to the template where the code had been called from. At ...
0
votes
1answer
85 views

Ordering stylesheet above <style> using functions.php

I'm loading a stylesheet and a style into the header using functions.php. This works but the stylesheet is being presented below the <style>. I need to order the stylesheet above the style ...
-1
votes
1answer
87 views

Errors while Loading Most Recent Version of jQuery

I am trying to set up my WordPress so that it will use the most recent version of jQuery. Here is what I have done so far: functions.php <? add_action( 'wp_enqueue_scripts', 'RegisterJQuery' ); ...
2
votes
1answer
317 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. ...
0
votes
1answer
85 views

Enqueueing scripts selectively & activation where needed

If I enqueue my scripts selectively, for instance I have a slider I only want to load on homepage, which is activated in main-js, e.g: wp_enqueue_script( 'main-js' ); if ( is_front_page() ) { ...
0
votes
1answer
348 views

loading javascript CDN with local fallback (not jQuery)

I'm trying to modify this to register and enqueue a jQuery plugin from a CDN with local fallback. However, when the URL fails (or if I give it a fake url) Firebug receives 2 aborted calls to the URL ...
1
vote
1answer
1k views

'jQuery is not defined Error' appearing in load-scripts.php

I'm writing this question having already found a solution, in order to see whether other people have encountered this problem. I was having a problem on the back end of a site I am building in ...
0
votes
2answers
2k views

Hook 'wp_enqueue_scripts' priority has no effect

In a theme I am working there are up to 3 Stylesheets. I am using the hook 'wp_enqueue_scripts'. The order of the stylesheets is important for overwriting styles. I have a code like this: ...
0
votes
1answer
407 views

force jQuery to load in the head

I've written a plugin which uses wp_enqueue_script("jquery"); to load jQuery. I need to load jQuery in the head and not at the bottom of the body. However, I think that this command is overwritten by ...
1
vote
1answer
158 views

Possible to enqueue scripts and CSS to Multisite Network dashboard?

Is it possible to enqueue scripts and css only to the Network Admin Dashboard? To edit the network admin menu, you have this hook: network_admin_menu, so I also tried network_admin_enqueue_scripts, ...
1
vote
2answers
241 views

Adding dependencies to script enqueing

What is the point of the dependencies parameter when using wp_enqueue_script()? For instance, when I do the following: wp_enqueue_script( 'jscripts', get_stylesheet_directory_uri() . ...
0
votes
2answers
617 views

Failing to load my script files in wordpress! i can't figure out what i'm doing wrong

i have customized my .html as a custom wp theme. i have these scripts in my header.php: <script type='text/javascript' src="scripts/jquery-1.8.2.js"></script> <script ...
1
vote
1answer
419 views

Move jQuery to the bottom of the page whilst keeping the WordPress jQuery

I wish to move jQuery to the bottom of the page on my theme, to speed up loading times. Previously I was doing this by replacing it with Google's CDN version but I have been told that is a bad thing ...
1
vote
1answer
461 views

wp_enqueue_script Doesn't Work?

It's pretty standard, I enqueue script and style for admin page. function admin_custom(){ wp_enqueue_script('js', plugins_url('adm.js', __FILE__)); wp_enqueue_style('css', ...
1
vote
2answers
124 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' ); ...
0
votes
1answer
2k views

Override default jquery ui library with newer version

The latest version of jquery ui core fixes a bug that's on my site. The problem is that Wordpress comes with an earlier version. How do I override the default jquery ui core? One solution I've found ...
0
votes
4answers
127 views

Help to enqueue a js functions ( jquery) [closed]

I have this js function (the textualizer.js is external) but I can't make it works on WordPress. Any help? I already added wp_register_script( 'textualizer', WP_THEME_URL . ...
1
vote
1answer
96 views

Enqueue AWS Script

I am working on the integration of an Amazon Webstore (Amazon Checkout) on a WordPress site using Amazon Documentation here. Has been a while since I worked with enqueueing external JScripts. I need ...
3
votes
1answer
642 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.
0
votes
2answers
45 views

Including Javascript options

For a Wordpress Theme I know javascript files (ending in .js) must be included using wp_enqueue_script in functions.php but how do I include additional javascript code, for example say I need to add ...
1
vote
1answer
404 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), ...
0
votes
1answer
87 views

Why is this function crashing my wordpress installation? [closed]

I'm new to wordpress and programming in general. For my first site there is a custom template in which I want to load a javascript library. After registering and enqueueing it in functions.php my site ...
0
votes
1answer
2k views

chosen jquery library not loading - is not a function error

I am trying to load the chosen library: http://harvesthq.github.com/chosen/ I am enqueuing a .js file as below: wp_register_script( 'js_custom', plugin_dir_url( __FILE__ ) . 'js/jquery.js', false ); ...
1
vote
2answers
185 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' ); ...
0
votes
1answer
77 views

Enqueue ONLY Plugin Styles and Scripts

Is there a way to enqueue only plugin styles and scripts without wp_head? I have a plugin I'm working on which overrides the page template, but I still want to include all other plugins without ...
0
votes
1answer
59 views

why quotes shown in Wordpress?

I have written a function to register a script in the admin interface. function custom_admin_js() { $url = get_bloginfo('template_directory') . '/admin/admin.js'; echo '<script ...
0
votes
1answer
325 views

Register script/style: Is it possible to customize the version query string via plugin?

Expanding on the question in the title: I would like to find a way (via a plugin) to use timestamps for the JS and CSS file version query strings that are output with wp_register_style and ...
0
votes
1answer
181 views

“admin_enqueue_scripts” hook or $_GET['page']?

When adding a function to "admin_enqueue_scripts" a hook is passed to the function. It looks like this "toplevel_page_nameofyourpage". That works great, but how is it different from checking the $_GET ...
0
votes
2answers
174 views

Is the wp_enqueue method efficient?

I had a quick question regarding how you are supposed to load in scripts with Wordpress. I am developing a theme and I know that the best way to do this is to use the ...
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 ...
0
votes
1answer
346 views

How to enqueue script based on post category?

I have scripts for various little tools I have made using some js and html. I want the js to load only on specific single posts in side a specific category. I have tried the following code and it does ...
3
votes
1answer
315 views

Is it safe/recommended to use wp_enqueue_script function outside the functions.php file?

I created multiple post formats, and when i use an audio post format, i want to include some additional javascript for the audio player. So, i include the content-audio.php like this: <?php ...
2
votes
1answer
2k views

How can I enqueue protocol relative external (//ajax.googleapis.com/…) scripts?

According to the Codex, wp_enqueue_script supports protocol relative, or protocol agnostic external links: "Remote assets can be specified with a protocol-agnostic URL, i.e. ...
2
votes
2answers
2k 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
1answer
192 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
640 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 ...
0
votes
1answer
154 views

How do I pass $in_foooter to wp_enqueue_script() without passing other params?

I have some scripts that I'm enqueueing like this: wp_enqueue_script("jquery"); wp_enqueue_script("myscript" , get_template_directory_uri()."/js/myscript.js", Array('myscript'), " "); I want to ...
0
votes
2answers
514 views

Including javascript for a shortcode

I'm creating a plugin that allows a user to use a shortcode. This shortcode depends on a bunch of javascript that needs to be present once the shortcode loads. I'm having issues trying to decide when ...
7
votes
1answer
4k views

When should I use wp_register_script() with wp_enqueue_script() vs just wp_enqueue_script()?

I'm having trouble understanding when you need to use wp_register_script(). Currently, I just use something like: add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) ); function enqueue() ...
0
votes
2answers
192 views

All of my Scripts and Enques are getting file not found

I have the following script and enque function, and the site properly renders it in the html head, however when I click the link to the css and javascript files the i get a url not found, however the ...
0
votes
1answer
642 views

wp_localize_script & wp_enqueue_script not working in front end

Here is my code snippet : wp_enqueue_script( 'ajax-script', get_stylesheet_directory_uri().'/js/myajax.js', array('jquery'), 1.0 ); wp_localize_script( 'ajax-script', 'ajax_object', array( 'ajaxurl' ...
2
votes
1answer
955 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'); ...
0
votes
1answer
204 views

Why is it wrong to use admin_print_scripts-{hook} to enqueue a script (.js) file?

According to the Codex, it should only be used for inline script tag(s) in the head. I've been using add_action('admin_print_scripts-{my-hook}' for injecting .js and ...
-1
votes
4answers
242 views

Can't get jQuery to enqueue into post edit script

In the code below, unless I hardcode a reference to the jQuery library, my jQuery bits on the page do not work. What's wrong with the enqueue method I'm trying to use? In functions.php: ...
0
votes
1answer
196 views

colorbox not loading in <head>

I can not get colorbox fully loaded. I am trying to add color box to use in my plugin admin. I do not need it for the front end. I can get the css but can not get jquery.colorbox-min.js or the ...
0
votes
2answers
136 views

If a Script has been enqueued but not registered can I still removed it?

There is a plugin that's conflicting with mine when the user loads the admin pages of my plugin, therefore I want to deregister and remove the conflicting script on these pages. Here is the code for ...