Tagged Questions
0
votes
0answers
27 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 ...
0
votes
1answer
47 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 ...
2
votes
1answer
111 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
62 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
94 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 ...
0
votes
2answers
489 views
Setting Variable Path to Template Directory inside Script
I have HTML5 Template with 5 pages. I am converting it to a WordPress Theme.
I have a contact page. This page includes 'forms.js' script to send contact form data to 'MailHandler.php' file.
Inside ...
1
vote
1answer
331 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?
3
votes
2answers
174 views
What are the benefits of using wp_enqueue_script?
Is there any real benefit to using wp_enqueue_script on small self-managed sites? For instance, Modernizr, why enqueue it through a function rather than call it directly inside the document head?
I ...
8
votes
2answers
297 views
Conditionally enqueue a widget's script/stylesheet in HEAD (only when present on page!)
I've been trying to load scripts and styles for a WordPress widget with the following conditions...
The scripts MUST load in the HEAD (else they break).
The scripts must ONLY load when the widget ...
1
vote
1answer
183 views
Help with enqueing scripts in footer after init action
In my functions.php, I have set a register_scripts() and load_scripts(), and hooked them to the 'init' action.
I have registered all the scripts to be loaded in the footer, in order to optimize page ...
0
votes
1answer
723 views
wp_enqueue_script() not working
I'm trying to add this social-network button:
<a href="http://svejo.net/submit/?url=[your url]"
data-url="[your url]"
data-type="compact"
id="svejo-button">Add in Svejo</a>
...
1
vote
1answer
349 views
Is there a way to list all the JavaScript scripts that are actually loaded by WordPress? Do we care?
This page on the Codex gives us a list of all the default scripts that ship with WP. But how do we know which ones are actually being used so we don't have to manually enqueue them? Or do we care, and ...
0
votes
1answer
129 views
Enqueuing a script before anything else
I wondered if it was possible to change the order in which a script is enqueued.
I ask this because I wish to include the HTML5 enabling script but it needs to be included before any styles.
Is ...
0
votes
1answer
265 views
What's a good way to unenqueue all scripts for a single template page?
I've found that my attachment templates are inheriting the enqueued scripts for single posts. My first instinct was to unenqueue these scripts one-by-one or to do an is_attachment() check before ...