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

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 
                        //These are the scripts. 
                        //NOTE: Gravity forms automatically includes only the scripts it needs, so be careful here. 
Share Aaron Jerad Designs on Facebook


  1. John · April 21, 2016 Reply

    Aaron, I was going nuts trying to find a function that would remove gform css from WP pages. It appears yours is the only up to date advice on this subject. Thanks much! 🙂

  2. C R · July 13, 2016 Reply

    Thanks so much- this was great.
    Can you help me for removing styles from a form id?
    So far I wrote the following but it’s not working..

    add_action(“gform_enqueue_scripts”, “gform_deregister_scripts”);
    function gform_deregister_scripts(){
    if(‘/[gravityform(.*?)id=7(.*?)]/’) {

    • Aaron Jerad · July 13, 2016 Reply

      I think you were really close with your code to remove gravity forms by the form ID.
      It looks like you are using a regex but are missing the preg_match… try something like this: (untested)

      add_action(“gform_enqueue_scripts”, “remove_gravityforms_by_id”);
      function remove_gravityforms_by_id() {
      global $post;
      if(preg_match('/[gravityform(.*?)id=7(.*?)]/', $post->post_content, $matches)) {
      //or any of the the other gforms scripts and styles.

Leave a Reply