Disable loading of styles and scripts if not necessary
-
Hi,
first of all Thanks for the great work!
Im using nextgen in the backend for managing images etc. and in the frontend just to get some json via the legacy template view. Mostyl URL’s and ALT Tags.
So i dont need the NextGen Script’s and Styles to load despite in the Backend.In Versions < 2 it was quit easy with
if (!is_admin()) { // goodbye NextGen Script define('NGG_SKIP_LOAD_SCRIPTS', true); }
and some
wp_deque_style
That wont work anymore!
Is there an easy way to keep the S&S from loading?Out of despair i tried bruteforcingly removing the S&S i found like
function nextgen_styles() { wp_dequeue_style('NextGEN'); wp_dequeue_style('ngg-slideshow'); wp_dequeue_style('shutter'); } function nextgen_scripts() { wp_deregister_script('ngg_common'); wp_deregister_script('ngg-common'); wp_deregister_script('ngg_social_media'); wp_deregister_script('photocrati_ajax'); wp_deregister_script('ngg-ajax'); wp_deregister_script('ngg-progressbar'); wp_deregister_script('ngg-autocomplete'); wp_deregister_script('ngg-colorpicker'); wp_deregister_script('ngg-autocomplete'); wp_deregister_script('nextgen_basic_thumbnails'); wp_deregister_script('nextgen_basic_thumbnails_settings'); wp_deregister_script('nextgen_basic_slideshow'); wp_deregister_script('nextgen_basic_slideshow_settings'); wp_deregister_script('nextgen_basic_extended_albums_script'); wp_deregister_script('nextgen_basic_extended_albums_settings_script'); wp_deregister_script('nextgen-basic-thumbnails-ajax-pagination'); wp_deregister_script('nextgen_gallery_display'); wp_deregister_script('nextgen_gallery_display_settings'); wp_deregister_script('nextgen_settings_page'); } add_action( 'wp_print_styles', 'nextgen_styles', 1); add_action( 'wp_print_scripts', 'nextgen_scripts', 1 ); add_action( 'wp_head', 'nextgen_styles', 1 ); add_action( 'wp_head', 'nextgen_scripts', 1 );
But this does not work even with priority set to 1 or 9999.
Am i on the wrong hooks or is it just not possible like that?As workaround i thougt of catching the header output, regexplacin all nextgen stuff and continue. But i dont like that solution.
Is there any Simple way of doin so?
Or is there somtehing like a “null” template avaible?Best regards,
Simon
- The topic ‘Disable loading of styles and scripts if not necessary’ is closed to new replies.