WordPress: Remove Unwanted Scripts and Stylesheets

| Ngoc Nguyen

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 . ' | ';

	// Runs through the queue styles
	foreach( $wp_styles->queue as $handle ) :
		$styles_list .= $handle . ' | ';

	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_script('comment-reply ');

add_action( 'wp_print_styles', 'wpcustom_deregister_scripts_and_styles', 100 );

You May Also Like:

116 thoughts on “WordPress: Remove Unwanted Scripts and Stylesheets

  1. Pingback: canadian pharmacies without an rx

  2. Pingback: alewrt.flazio.com

  3. Pingback: graph.orgPharmacies-in-canada-shipping-to-usa-08-12

  4. Pingback: prescription drugs without prior prescription

  5. Pingback: 500px.complistofcanadianpharmaceuticalsonline

  6. Pingback: https://challonge.com/en/canadianpharmaciesshippingtousa

  7. Pingback: https://reallygoodemails.com/canadianpharmaceuticalsonline

  8. Pingback: pinshape.comusers2441621-canadian-pharmaceutical-companies

  9. Pingback: online canadian pharmacies

  10. Pingback: buy stromectol fitndance

  11. Pingback: ivermectina

  12. Pingback: stromectol tablets uk

  13. Pingback: stromectol order online

  14. Pingback: reaction au stromectol

  15. Pingback: canadian drugs

  16. Pingback: challonge.comcitlitigolf

  17. Pingback: ivermectin

  18. Pingback: stromectol demodex

  19. Pingback: stromectol buy online

  20. Pingback: network.myscrs.orgprofile4220200

  21. Pingback: stromectol dosage table

  22. Pingback: stromectol online

  23. Pingback: stromectol india

  24. Pingback: buy ivermectin fitndance

  25. Pingback: stromectol for humans

  26. Pingback: pharmaceuticals.cgsociety.orgjvcccanadian-pharmaceuti

  27. Pingback: canadian pharmacies mail order

  28. Pingback: prescriptions from canada without

  29. Pingback: canadian discount pharmacies

  30. Pingback: https://scisevitrid.estranky.sk/clanky/canada-pharmacies.html

  31. Pingback: canadian pharmaceuticals online

  32. Pingback: drugstore online

  33. Pingback: https://bitbucket.org/canadianpharmaceuticalsonline/workspace/snippets/k7KRy4

  34. Pingback: highest rated canadian pharmacies

  35. Pingback: https://www.passivehousecanada.com/members/online-drugs-without-prescriptions-canada/

  36. Pingback: canada drug

  37. Pingback: canada pharmacies online

  38. Pingback: how to take liquid tadalafil

  39. Pingback: writing essay services

  40. Pingback: write my college essay me

  41. Pingback: college essay help service

  42. Pingback: order custom essays online

  43. Pingback: us essay writing services

  44. Pingback: history essay help

  45. Pingback: college application essay services

  46. Pingback: online essay writing service

  47. Pingback: online help with essay writing

  48. Pingback: affordable essay writing service

  49. Pingback: online essay writers wanted

  50. Pingback: college essay writing services

  51. Pingback: pay for essay cheap

  52. Pingback: online custom essays

  53. Pingback: custom essays online

  54. Pingback: tadalafil 100mg

  55. Pingback: generic sildenafil 20mg cost

  56. Pingback: sildenafil citrate 50 mg

  57. Pingback: sildenafil online in india

  58. Pingback: tadalafil rx

  59. Pingback: best place to buy tadalafil online

  60. Pingback: tadalafil treatment for painful erection

  61. Pingback: neurontin erfaringer

  62. Pingback: tylenol metronidazole

  63. Pingback: valtrex surdose

  64. Pingback: nolvadex-d bijwerkingen

  65. Pingback: furosemide logo

  66. Pingback: metformin kreft

  67. Pingback: rybelsus 3 mg oral tablet

  68. Pingback: zoloft vs.effexor

  69. Pingback: lexapro and weight loss

  70. Pingback: difference between cymbalta and lexapro

  71. Pingback: keflex cephalexin 500 mg 20 capsules

  72. Pingback: gabapentin analogues

  73. Pingback: duloxetine maximum dose

  74. Pingback: olanzapine/fluoxetine reviews

  75. Pingback: cephalexin not refrigerated

  76. Pingback: ciprofloxacin eye drops

  77. Pingback: strep throat amoxicillin

  78. Pingback: citalopram 40 mg side effects

  79. Pingback: how long does it take for flexeril to work

  80. Pingback: ddavp use in pregnancy

  81. Pingback: contrave qsymia

  82. Pingback: ezetrol ezetimibe

  83. Pingback: effexor for anxiety

  84. Pingback: augmentin for dogs

  85. Pingback: aripiprazole drug

  86. Pingback: expired aspirin

  87. Pingback: allopurinol and colchicine together

  88. Pingback: can i drink alcohol while taking augmentin

  89. Pingback: bupropion 300 xl

  90. Pingback: celexa vs lexapro

  91. Pingback: dosage for celebrex

  92. Pingback: diltiazem 24hr er 120 mg cap

  93. Pingback: protonix pill

  94. Pingback: abilify cost per month

  95. Pingback: repaglinide emivita

  96. Pingback: amitriptyline for sleep and anxiety

  97. Pingback: acarbose controindicazioni

  98. Pingback: actos revolucionarios

  99. Pingback: sitagliptin dosage

  100. Pingback: stromectol covid

  101. Pingback: voltaren gel price

  102. Pingback: cipro and tizanidine interaction

  103. Pingback: sildenafil 50 mg tablet

  104. Pingback: Cytotec

  105. Pingback: ivermectin tablet price

  106. Pingback: sildenafil citrate 100mg

  107. Pingback: ivermectin 4

  108. Pingback: tadalafil dosage instructions

  109. Pingback: neurontin for suboxone withdrawal

  110. Pingback: can lyrica cause weight gain

  111. Pingback: tamoxifen retinopathy

  112. Pingback: cephalexin monohydrate

  113. Pingback: can i take keflex if allergic to penicillin

  114. Pingback: what are the side effects of metformin

  115. Pingback: ciprofloxacin alternative

  116. Pingback: lisinopril potassium

Comments are closed.