Community Forums › Forums › Archived Forums › General Discussion › Can't disable css files.
- This topic has 9 replies, 3 voices, and was last updated 8 years, 3 months ago by hugh71158.
-
AuthorPosts
-
December 18, 2015 at 1:08 am #174180hugh71158Member
Hi,
I have created a custom css stylesheet, and entering the URL in a browser shows me it is working ok. However, I can't get the files it is supposed to replace to stop loading. Can anyone see where I am going amiss? The code I am using in the functions.php file in my Dynamik theme is:
// Disable CSS Site-Wide Using CSS Script Handle add_action( 'wp_print_styles', 'my_deregister_styles', 100 ); function my_deregister_styles() { wp_deregister_style( 'dynamik_minified_stylesheet' ); wp_deregister_style( 'font-awesome' ); wp_deregister_style( 'fl-builder-layout-6' ); wp_deregister_style( 'gd-full-width' ); wp_deregister_style( 'gforms_reset_css' ); wp_deregister_style( 'gforms_formsmain_css' ); wp_deregister_style( 'gforms_ready_class_css' ); wp_deregister_style( 'gforms_browsers_css' ); wp_deregister_style( 'gforms_datepicker_css' ); }
Any help is appreciated.
Thanks!
Hugh
Venture Photography
December 18, 2015 at 10:09 am #174216jesephMemberTry replacing 'wp_print_styles' with 'wp_enqueue_scripts'
wp_print_styles is a depreciated hook https://make.wordpress.org/core/2011/12/12/use-wp_enqueue_scripts-not-wp_print_styles-to-enqueue-scripts-and-styles-for-the-frontend/
December 18, 2015 at 10:22 am #174218hugh71158MemberHi, thanks for the reply. I changed it to the code below - still the css files are all loading. 🙁
Hugh
// Disable CSS Site-Wide Using CSS Script Handle add_action( 'wp_enqueue_scripts', 'my_deregister_styles', 100 ); function my_deregister_styles() { wp_deregister_style( 'dynamik_minified_stylesheet' ); wp_deregister_style( 'font-awesome' ); wp_deregister_style( 'fl-builder-layout-6' ); wp_deregister_style( 'gd-full-width' ); wp_deregister_style( 'gforms_reset_css' ); wp_deregister_style( 'gforms_formsmain_css' ); wp_deregister_style( 'gforms_ready_class_css' ); wp_deregister_style( 'gforms_browsers_css' ); wp_deregister_style( 'gforms_datepicker_css' ); }
Venture Photography
December 18, 2015 at 10:23 am #174219jesephMemberSorry, moving too fast, also try changing wp_deregister_style to wp_dequeue_style
December 18, 2015 at 11:07 am #174229hugh71158MemberYeah, it steadfastly refuses to work. Sorry for being a pain. I appreciate the effort. I tried:
// Disable CSS Site-Wide Using CSS Script Handle add_action( 'wp_enqueue_scripts', 'my_dequeue_styles', 100 ); function my_deregister_styles() { wp_dequeue_style( 'dynamik_minified_stylesheet' ); wp_dequeue_style( 'font-awesome' ); wp_dequeue_style( 'fl-builder-layout-6' ); wp_dequeue_style( 'gd-full-width' ); wp_dequeue_style( 'gforms_reset_css' ); wp_dequeue_style( 'gforms_formsmain_css' ); wp_dequeue_style( 'gforms_ready_class_css' ); wp_dequeue_style( 'gforms_browsers_css' ); wp_dequeue_style( 'gforms_datepicker_css' ); }
Venture Photography
December 18, 2015 at 11:10 am #174230jesephMemberIn this latest version you're adding a function called my_dequeue_styles but the function is named my_deregister_styles
make sure those match 🙂
December 18, 2015 at 11:17 am #174231hugh71158MemberAh!! I think I have it now, but still all the stylesheets are loading. ???
// Disable CSS Site-Wide Using CSS Script Handle add_action( 'wp_enqueue_scripts', 'my_dequeue_styles', 100 ); function my_dequeue_styles() { wp_dequeue_style( 'dynamik_minified_stylesheet' ); wp_dequeue_style( 'font-awesome' ); wp_dequeue_style( 'fl-builder-layout-6' ); wp_dequeue_style( 'gd-full-width' ); wp_dequeue_style( 'gforms_reset_css' ); wp_dequeue_style( 'gforms_formsmain_css' ); wp_dequeue_style( 'gforms_ready_class_css' ); wp_dequeue_style( 'gforms_browsers_css' ); wp_dequeue_style( 'gforms_datepicker_css' ); }
Venture Photography
December 21, 2015 at 11:24 pm #174534coralseaitMemberTry both wp_dequeue and wp_dergeister with a priority on your action of very high, say 99999
so something like:
// Disable CSS Site-Wide Using CSS Script Handle add_action( 'wp_enqueue_scripts', 'my_dequeue_styles', 99999); function my_dequeue_styles() { wp_dequeue_style( 'dynamik_minified_stylesheet'); wp_deregister_style( 'dynamik_minified_stylesheet'); }
For brevity I just listed a single example of dequeue and deregister in the function, you'd add all of them in it so each script is dequeued and deregistered.
December 21, 2015 at 11:27 pm #174535coralseaitMemberOh yes, make sure there's no caching occuring, you may have a server cache that needs flushing as well, not sure
December 22, 2015 at 7:59 am #174548hugh71158MemberThanks, I'll try that.
I was getting nowhere with this, and I had been stuck on a Pagespeed score of 71/100, but installing a plugin called Autoptomize solved the issue for me. I managed to get to 100/100.
So, it's now a question of which way to head with this.
Thanks!!!
Venture Photography
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.