How to Make Google Jquery Library Async or Defer?

Use script_loader_tag to modify the HTML before printing. apply_filters( ‘script_loader_tag’, string $tag, string $handle, string $src ) add_action( ‘init”https://wordpress.stackexchange.com/questions/236811/,”replace_jquery_src’ ); /** * Modify loaded scripts */ function replace_jquery_src() { if ( ! is_admin() ) { // Remove the default jQuery wp_deregister_script( ‘jquery’ ); // Register our own under ‘jquery’ and enqueue it wp_register_script( ‘jquery”https://wordpress.stackexchange.com/questions/236811/,”http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js’, false, … Read more

Display a function using AJAX

You’re not hooking the function to wp_ajax correctly. You need to replace the my_action part with your action name that you’re using the in AJAX request. In your case it’s display_user_table. You also need to hook it on to wp_ajax_nopriv so that it works for logged out users. Here’s your hook with those changes: add_action(‘wp_ajax_diplay_user_table’, … Read more

Registering jQuery kills admin functions

jQuery is not defined This is because the Google CDN Jquery is not in no-conflict mode. Use the following to make sure the included WordPress no-conflict jquery is used in admin. if( !is_admin()){ wp_deregister_script(‘jquery’); wp_register_script(‘jquery’, (“http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js”), false, ‘1.4.2’); wp_enqueue_script(‘jquery’); }

How do I activate jQuery/script on demand?

1. Register jQuery and the plugin within your head wp_register_script( ‘jquery’ ); wp_register_script( ‘your_jquery_plugin’, STYLESHEETPATH, ‘jquery’, ‘0.0’, false ); 2. Register a meta box It should be a simple checkbox. Please do it like it’s described on the codex page for add_meta_box() (don’t just repeat this one here). If you follow the rest, then the … Read more

Enqueuing jQuery in plug-ins

First of all, if your code (or the theme’s code) is unregistering jQuery and re-registering it from another location (Google), you need to add this somewhere: jQuery.noConflict(); This makes jQuery cooperate with other scripts (i.e. Prototype) that try to define the $ variable globally. WordPress has this line bundled into their version, Google does not. … Read more