Skip to main content

Posts

Showing posts from February, 2020

Wordpress replace jQuery with the Google API version + FallBack to local

__________________________________________________________ https://wordpress.stackexchange.com/questions/12448/how-to-replace-regular-jquery-calls-with-cdn-calls-from-google/12450 Notice that I'm still using WordPress' dependency management system. Also, sets HTTPS vs HTTP using  is_ssl()  to avoid mixed content errors, and lets WordPress dictate version number. //// REPLACE JQUERY WITH THE GOOGLE API version +++ get local wp version add_action( 'init', function(){     //Only act if is admin     if (  ! is_admin()) {         //set protocol dynamically         if( is_ssl() ){             $protocol = 'https';         }else {             $protocol = 'http';         }         /** @var WP_Scripts $wp_scripts */         global  $wp_scripts;     ...

Wordpress - remove unneeded JS and CSS from a page

https://stackoverflow.com/questions/35980246/remove-js-and-css-from-a-template-in-wordpress Try to use this in functios.php first: function remove_head_scripts () {    global $wp_styles ;    var_dump ( $wp_styles );    global $wp_scripts ;    var_dump ( $wp_scripts ); } add_action ( 'wp_enqueue_scripts' , 'remove_head_scripts' , 101 ); Then you can see all of the enqueued styles & scripts with their respective slugs printed. After you know exact slugs of your script & style, replace snippet above with new one: function remove_head_scripts () { wp_dequeue_style    wp_dequeue_style ( 'exact_style_slug' );    wp_dequeue_script ( 'exact_script_slug' ); } add_action ( 'wp_enqueue_scripts' , 'remove_head_scripts' , 101 ); ____________________________________________________________ https://stackoverflow.com/questions/44152718/remove-wordpress-plugin-js-and-css-files-from-inappropriate-pa...