Home > plugin development > should i be checking for jquery before enqueing it in a plugin

should i be checking for jquery before enqueing it in a plugin

September 14Hits:1
Advertisement

At the start of a typical plugin which uses jquery I have something like the following

wp_deregister_script('jquery'); wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js', false, '1.3.2'); wp_enqueue_script('jquery'); 

Which as I understand it deregisters and re-enqueues jquery ( from google in this example but that's irrelevant here )

My question is this: is there not some way of checking to see whether the library is already enqueued ( by another plugin or the theme) to save needless deregister/register and enqueue ( or is this not very expensive in reality )

Answers

Enqueues are not piling up if done multiple times (that is kinda the point of having a queue).

As for registration - frankly it shouldn't be done by most (public) plugins. WordPress comes with jQuery to use and when that copy is re-registered to something else - it affects all plugin and theme code that depends on it.

If it's private code - just do registration once somewhere, no need to duplicate it.

Related Articles

  • should i be checking for jquery before enqueing it in a pluginSeptember 14

    At the start of a typical plugin which uses jquery I have something like the following wp_deregister_script('jquery'); wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js', false, '1.3.2'); wp_enqueue_script(

  • Check if jquery library existAugust 8

    How to check if jQuery library exist in head tags? <head> <script type="javascript/text" src="http://code.jquery.com/jquery-1.6.2.js"></script> </head> and if not exist how do I load in head tags the jquery libr

  • 10+ jQuery Web Tour, Help and Instructional Plugins

    10+ jQuery Web Tour, Help and Instructional PluginsJuly 26

    Take your user experience to another level by incorporating one of these pretty interesting jQuery Web Tour, Help and Instructional Plugins in your website. You would find these plugins really useful for improving your overall user experience on your

  • 10 Worth Checking Out jQuery Plugins

    10 Worth Checking Out jQuery PluginsFebruary 2

    Everyday talented and imaginative coders release jQuery plugins to help us developers make our website attractive and most of all dynamic. Today's post is another set of jQuery plugins that are worth checking out! Enjoy! Related Posts: 10 Nouveau CSS

  • Check with jQuery value of checkbox from custom admin panelJanuary 9

    i am trying to create my first admin panel for my theme. I have a simple checkbox which i think is working. Where is this information stored? Is this information stored in the database? How can i then check it's value? I would like to read this value

  • Unable to show/hide button on checkbox check in jQueryJanuary 20

    I'm using ASP.NET checkbox controls. And what I'm trying to do is to simply change visibility of button on checkbox change event. If checkbox is checked then hide button, else if it is unchecked show the button. I have 2 problems with my jQuery code.

  • Triggering jQuery code attached to a radio button when this button gets checked through jQuery elsewhereJanuary 21

    In some plugin the following code runs when a radio button is manually checked: ;(function ( $, window, document, undefined ) { $.fn.wc_variation_form = function() { var $form = this; $form.on( 'change', '.variations input:radio', function() { // thi

  • Column wise calculation of checked fields JqueryJanuary 25

    I have records which is displaying the data from MYSQL db in PHP Also i have provided a checkbox, if the user checks the particular column checkbox, that particular column total has to displayed in the bottom. I can have multiple columns. Iam just co

  • Checking if radio is checked doesn't work when the radio is checked using jQueryFebruary 17

    I need to dynamically set textarea as required or not but it doesn't want to work properly. JQuery check it itself but then can't check if it's checked or not. But when you clicked inside the second radio, the textarea is always required. I tried man

  • jQuery form preview using the Instagram pluginMay 11

    How can I improve my jQuery form preview implementation? I'm currently using the jQuery Instagram Plugin to get the hashtag from Instagram. var timeoutReference; var element; var tagsa; $(document).ready(function() { $('input#instagram_hashtag_hashta

  • jquery code didnt run on my pluginJanuary 18

    I use this to hook my scripts and styles to my plugin add_action('admin_init', 'the_box_init' ); // Init plugin options to white list our options function the_box_init(){ register_setting( 'the_box_options', 'the_box', 'the_box_validate' ); wp_enqueu

  • Cannot get jQuery UI to enqueue in my plugin!December 12

    Not sure what I'm doing wrong, but I could use some help. My plugin architecture is below... register_activation_hook(__FILE__, 'my_post_options_box'); add_action('admin_menu', 'my_post_options_box'); //enqueue jquery ui here function my_load_js() {

  • jQuery AJAX call not executing in PluginApril 9

    I've been working on a class for my free plugins that outputs a "Donate" form. The "No thanks" dismissal link hides the form and runs an AJAX call to update a WP Option keeping track of the dismissal. I'm having issues getting the call

  • Check if layer is a QGSVectorLayer from Python Plugin within QGISMay 9

    I am trying to extend some concepts in the QGIS Workshop tutorial. Basically, I would like to check if the layer is of type "QGSVectorLayer". In the QGIS Python console, I am able to type canvas = qgis.utils.iface.mapCanvas() cLayer = canvas.cur

  • Let plugin check if taxonomy is already registered by another pluginFebruary 10

    My site is using a custom taxonomy that can be associated with two different custom post types. Each post type is registered by a different plugin. It may be that only one of the plugins is active or that both are activated. My idea was to let each p

  • using jquery serialize in ajax operation for pluginJuly 13

    I am writing a plugin with dynamic no. of input fields in form. To submit form via ajax, I have used jquery serialize() function. $(".submit").submit(function( event ) { event.preventDefault(); var data = { action: 'wpaie_ajax_action', operation

  • Creating HTML table from JSON with JQuery, trying to sort with Tablesorter plugin, but not workingJanuary 19

    I'm having some trouble getting tablesorter to work with an HTML table that's being created with JQuery from JSON data. I get the table created, and the column headers highlight when I click them but it doesn't sort the data. The JQuery that creates

  • How can I check if any of my Firefox extensions or plugins are using the internet?April 6

    Is there a way to monitor if Firefox extensions or plugins are using the internet? --------------Solutions------------- I'm fairly sure Firebug can track extension XHRs in its NET tab. You could also use a packet inspector such as Wireshark to see wh

  • Is it possible to check is loaded language files correctly with WordPress plugin?November 16

    I have a plugin to be translated. I have done following tasks: 1. Loaded the TextDomain $my_td = 'mysignup'; function my_signup_textdomain_init() { load_plugin_textdomain( $my_td, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); } add

  • jQuery Check if an Element ExistsApril 4

    jQuery code snippet to check whether a html element exists on the current web page. The easiest way i've found to do this is to check the length of an object to see if it exists in the DOM. //check if an element exists by using length if ($("#id"

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 3.597 s.