WordPress: Remove Unwanted Scripts and Stylesheets
I use NextGen gallery to organize my images and photos, but I don’t use it to display the galleries on my site. In order to optimize site speed, I wanted to prevent Nextgen scripts and stylesheets from loading.
Getting the Scripts and Stylesheets Handle
Before, we can remove the scripts and stylesheets from loading, we need to know their handle names. The easiest way to do this is to edit the functions.php file. Afterwards we simply navigate to any page and the handle names will be printed out at the top.
function wpcustom_inspect_scripts_and_styles() {
global $wp_scripts;
global $wp_styles;
// Runs through the queue scripts
foreach( $wp_scripts->queue as $handle ) :
$scripts_list .= $handle . ' | ';
endforeach;
// Runs through the queue styles
foreach( $wp_styles->queue as $handle ) :
$styles_list .= $handle . ' | ';
endforeach;
printf('Scripts: %1$s Styles: %2$s',
$scripts_list,
$styles_list);
}
add_action( 'wp_print_scripts', 'wpcustom_inspect_scripts_and_styles' );
Removing the Unwanted Scripts and Stylesheets
Now that we have the handle names, we can call wp_deregister_style() to remove the unwanted scripts and stylesheets. In the sample below, I am removing the Nextgen scripts and lightbox stylesheets from firing throughout the site. If you need to remove them only for specific pages or sections, you can use WordPress’ conditional tags.
function wpcustom_deregister_scripts_and_styles(){
wp_deregister_style('foobox-1-4-min');
wp_deregister_style('foobox-mini-invert');
wp_deregister_style('foobox-blue');
wp_deregister_script('photocrati_ajax');
wp_deregister_script('lazy_resources');
wp_deregister_script('comment-reply ');
}
add_action( 'wp_print_styles', 'wpcustom_deregister_scripts_and_styles', 100 );
Pingback: canadian pharmacies without an rx
Pingback: alewrt.flazio.com
Pingback: graph.orgPharmacies-in-canada-shipping-to-usa-08-12
Pingback: prescription drugs without prior prescription
Pingback: 500px.complistofcanadianpharmaceuticalsonline
Pingback: https://challonge.com/en/canadianpharmaciesshippingtousa
Pingback: https://reallygoodemails.com/canadianpharmaceuticalsonline
Pingback: pinshape.comusers2441621-canadian-pharmaceutical-companies
Pingback: online canadian pharmacies
Pingback: buy stromectol fitndance
Pingback: ivermectina
Pingback: stromectol tablets uk
Pingback: stromectol order online
Pingback: reaction au stromectol
Pingback: canadian drugs
Pingback: challonge.comcitlitigolf
Pingback: ivermectin
Pingback: stromectol demodex
Pingback: stromectol buy online
Pingback: network.myscrs.orgprofile4220200
Pingback: stromectol dosage table
Pingback: stromectol online
Pingback: stromectol india
Pingback: buy ivermectin fitndance
Pingback: stromectol for humans
Pingback: pharmaceuticals.cgsociety.orgjvcccanadian-pharmaceuti
Pingback: canadian pharmacies mail order
Pingback: prescriptions from canada without
Pingback: canadian discount pharmacies
Pingback: https://scisevitrid.estranky.sk/clanky/canada-pharmacies.html
Pingback: canadian pharmaceuticals online
Pingback: drugstore online
Pingback: https://bitbucket.org/canadianpharmaceuticalsonline/workspace/snippets/k7KRy4
Pingback: highest rated canadian pharmacies
Pingback: https://www.passivehousecanada.com/members/online-drugs-without-prescriptions-canada/
Pingback: canada drug
Pingback: canada pharmacies online
Pingback: how to take liquid tadalafil
Pingback: writing essay services
Pingback: write my college essay me
Pingback: college essay help service
Pingback: order custom essays online
Pingback: us essay writing services
Pingback: history essay help
Pingback: college application essay services
Pingback: online essay writing service
Pingback: online help with essay writing
Pingback: affordable essay writing service
Pingback: online essay writers wanted
Pingback: college essay writing services
Pingback: pay for essay cheap
Pingback: online custom essays
Pingback: custom essays online
Pingback: tadalafil 100mg
Pingback: generic sildenafil 20mg cost
Pingback: sildenafil citrate 50 mg
Pingback: sildenafil online in india
Pingback: tadalafil rx
Pingback: best place to buy tadalafil online
Pingback: tadalafil treatment for painful erection
Pingback: neurontin erfaringer
Pingback: tylenol metronidazole
Pingback: valtrex surdose
Pingback: nolvadex-d bijwerkingen
Pingback: furosemide logo
Pingback: metformin kreft
Pingback: rybelsus 3 mg oral tablet
Pingback: zoloft vs.effexor
Pingback: lexapro and weight loss
Pingback: difference between cymbalta and lexapro
Pingback: keflex cephalexin 500 mg 20 capsules
Pingback: gabapentin analogues
Pingback: duloxetine maximum dose
Pingback: olanzapine/fluoxetine reviews
Pingback: cephalexin not refrigerated
Pingback: ciprofloxacin eye drops
Pingback: strep throat amoxicillin
Pingback: citalopram 40 mg side effects
Pingback: how long does it take for flexeril to work
Pingback: ddavp use in pregnancy
Pingback: contrave qsymia
Pingback: ezetrol ezetimibe
Pingback: effexor for anxiety
Pingback: augmentin for dogs
Pingback: aripiprazole drug
Pingback: expired aspirin
Pingback: allopurinol and colchicine together
Pingback: can i drink alcohol while taking augmentin
Pingback: bupropion 300 xl
Pingback: celexa vs lexapro
Pingback: dosage for celebrex
Pingback: diltiazem 24hr er 120 mg cap
Pingback: protonix pill
Pingback: abilify cost per month
Pingback: repaglinide emivita
Pingback: amitriptyline for sleep and anxiety
Pingback: acarbose controindicazioni
Pingback: actos revolucionarios
Pingback: sitagliptin dosage
Pingback: stromectol covid
Pingback: voltaren gel price
Pingback: cipro and tizanidine interaction
Pingback: sildenafil 50 mg tablet
Pingback: Cytotec
Pingback: ivermectin tablet price
Pingback: sildenafil citrate 100mg
Pingback: ivermectin 4
Pingback: tadalafil dosage instructions
Pingback: neurontin for suboxone withdrawal
Pingback: can lyrica cause weight gain
Pingback: tamoxifen retinopathy
Pingback: cephalexin monohydrate
Pingback: can i take keflex if allergic to penicillin
Pingback: what are the side effects of metformin
Pingback: ciprofloxacin alternative
Pingback: lisinopril potassium