Skip to content

Instantly share code, notes, and snippets.

@mdawaffe
Created June 18, 2012 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdawaffe/2951506 to your computer and use it in GitHub Desktop.
Save mdawaffe/2951506 to your computer and use it in GitHub Desktop.
WordPress (Ill-Advised) Hack: I Already Load jQuery "Manually"
<?php
/*
* Plugin Name: I Already Load jQuery "Manually" Hack
* Plugin URI: https://gist.github.com/2951506
* Description: If you already load jQuery manually (i.e., without using WordPress' script API), this plugin will prevent other plugins that *do* use WordPress' script API from "double" loadin jQuery. There are probably better ways to prevent this unwanted double-loading behavior. If you have to use this plugin, you're probably doing_it_wrong(). Use at your own risk, it probably breaks something.
* Author: mdawaffe
* Version: 0.1
* Author URI: http://blogwaffe.com
* License: GPL2+
*/
if ( !is_admin() ) {
// Hack: This reregisters the 'jquery' handle as a "group" instead of script.
// That way, a script tag won't be printed, but wp_print_scripts() won't
// treat the 'jquery' handle as missing, which would stop it from loading other
// scripts that depend on jquery
wp_register_script( 'jquery', false );
}
@mdawaffe
Copy link
Author

This is a proof of concept. I wouldn't use this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment