Quantcast
Channel: AJ Designs
Viewing all articles
Browse latest Browse all 69

How to Remove Gravity Forms CSS style-sheets and Scripts from Specific Pages

$
0
0

Gravity forms has a nice option in the settings area to remove it’s css output from all pages. However when you want to remove the style-sheets from individual pages it gets more complicated.

Here’s a simple function which will remove Gravity Forms CSS and selected scripts from the front_page:
Cut and paste this code into your functions.php file.


//Deregister Gravity Stylesheets and Scripts from specific pages

add_action("gform_enqueue_scripts", "deregister_scripts");

		function deregister_scripts(){
			
                     //Change this conditional to target whatever page or form you need.
			if(is_front_page()) { 
                        
                        //These are the CSS stylesheets 
			   wp_deregister_style("gforms_formsmain_css"); 	
			   wp_deregister_style("gforms_reset_css");
			   wp_deregister_style("gforms_ready_class_css");
			   wp_deregister_style("gforms_browsers_css");
			
                        //These are the scripts. 
                        //NOTE: Gravity forms automatically includes only the scripts it needs, so be careful here. 
			   //wp_deregister_script("gforms_conditional_logic_lib");
			   //wp_deregister_script("gforms_ui_datepicker");
			   //wp_deregister_script("gforms_gravityforms");
			   //wp_deregister_script("gforms_character_counter");
			   //wp_deregister_script("gforms_json");
			   //wp_deregister_script("jquery");
		}
	}

The post How to Remove Gravity Forms CSS style-sheets and Scripts from Specific Pages appeared first on Aaron Jerad Designs.


Viewing all articles
Browse latest Browse all 69

Trending Articles