How to control the order of the combination of enqueued styles and scripts – site speed issue

We know, using wp_head() and wp_footer() all the scripts and styles are enqueued using wp_enqueue_styles and wp_enqueue_scripts hook. What we do is to enqueue our stylesheets and scripts using functions.php. And similarly WordPress plugins also enqueue their stylesheets and scripts using the same method. So, in the end there are many enqueued styles and scripts … Read more

When does WordPress automatically enqueue jQuery?

I understood that WordPress ALWAYS enqueues jQuery on all themes, thus it’s reduntant to enqueue another jQuery with the same version. However, while developing a theme, for testing purposes I moved it to a subdomain (same domain, another WP installation, no content but the “Hello World” post). While the first enqueued normally the jQuery, the … Read more

How to include jquery validate in a template

I am attempting to load jquery’s validate methods in my template file. The idea is to be able to run something like this: $jquery(“#generateForm”).validate({ submitHandler: function(form) { $(form).ajaxSubmit(); }, rules: { … } }, messages: { … } } }); Based on several posts, I’ve put this in my header.php file: <?php function add_my_js_files(){ wp_enqueue_script(‘jquery-validate-min’, … Read more

wp_enqueue_script adds only the first script

function banana_scripts() { wp_enqueue_script(‘grid’, get_stylesheet_directory_uri() . ‘/js/jquery.min.js’, null, null); wp_enqueue_script(‘grid’, get_stylesheet_directory_uri() . ‘/js/main.js’, null, null); } add_action(‘wp_enqueue_scripts’, ‘banana_scripts’); I have the above hook in my functions.php. The first js file gets included, the second not. Is it incorrect to call this function twice or more? 1 Answer 1 You gave each each script the same … Read more

How to switch css files according to devices and button click?

I am trying to enqueue a responsive css file if the website is opened on mobile devices. Also I want to switch / enqueue a default or non-responsive css file when a button is clicked. The non-responsive css file is the default style sheet which is loaded on desktop. So the requirements are: By default … Read more

wp_enqueue_script with dependencies doesn’t work

I’m having this code: wp_register_script(‘parent’,’parent.js’, array(‘child’), ‘1’, true); wp_register_script(‘child’, ‘child.js’, array(‘grandchild’), ‘1’, true); wp_register_script(‘grandchild’, ‘grandchild.js’, array(), ‘1’, true); wp_enqueue_script(‘parent’); and it works fine, rendering grandchild.js, then child.js, then parent.js in footer. Every combination of just parent and child works fine, regardless of TRUE or FALSE ‘render in footer’. But when I register ‘child’ to be … Read more

wp_enqueue_scripts not working inside shortcode

<?php class OrdersShortcode { function __construct() { add_shortcode(‘order_ajax_form’, array(&$this, ‘order_ajax_form’)); } function my_enqueued_assets() { wp_enqueue_script(‘my-script’, “//ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js”); wp_enqueue_script(‘my-script2’, plugin_dir_url(__FILE__) . ‘js/easyResponsiveTabs.js’); wp_enqueue_script(‘my-script3’, plugin_dir_url(__FILE__) . ‘js/fb.js’); wp_enqueue_script(‘my-script4’, plugin_dir_url(__FILE__) . ‘js/verify.js’); wp_enqueue_style(‘my-style’, plugin_dir_url(__FILE__) . ‘css/style.css’); wp_enqueue_style(‘my-style2’, plugin_dir_url(__FILE__) . ‘css/easy-responsive-tabs.css’); } function order_ajax_form() { add_action(‘wp_enqueue_scripts’, array( $this, ‘my_enqueued_assets’)); include(dirname(dirname(__FILE__)) . ‘/views/form.php’); } } I am trying to use wp_enqueue_scripts … Read more

Simple jQuery Click Not Working, though console log recognizes the function [closed]

Closed. This question is off-topic. It is not currently accepting answers. Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third party plugins and themes are off topic, they are better asked about at their developers’ support routes. Closed 4 … Read more