Hi, I’m building my first Wordpress site and I’m coming into the problem of generating excessive scripts in the header for pages that don’t need them. I’ve figured out how to disable a lot of these but I’m having a problem with NextGen Galleryview.
The way that I’ve learned how to disable scripts goes as such:
find the wp_enqueue_script (or wp_enqueue_style for css) that call for the specific name of the script (or css file).
find the name that is attached to that file
then deregister it in the functions.php file with an if statement targeted to pages that you don’t need the script
NextGen Galleryview doesn’t register it’s script in that way though this is how it calls those scripts:
function nggGalleryViewHead() {
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-core');
echo '<!-- begin nextgen-js-galleryview scripts -->
<script type="text/javascript" src="'.GALLERYVIEW_URL.'/GalleryView/scripts/jquery.timers-1.1.2.js"></script>
<script type="text/javascript" src="'.GALLERYVIEW_URL.'/GalleryView/scripts/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="'.GALLERYVIEW_URL.'/GalleryView/scripts/jquery.galleryview-2.0.js"></script>
<link type="text/css" href="'.GALLERYVIEW_URL.'/GalleryView/css/galleryview.css" rel="stylesheet" media="screen" />
<!-- end nextgen-js-galleryview scripts -->
';
}
I’ve tried rewriting this in the correct wp_enqueue_script/style format but it ends up throwing errors. Mostly because I’m new to Wordpress and php.
Is there a way to encase this into a add_action command or something like that so I can disable it from the functions.php page?