PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Gravity forms javscript conflict with autoptimize

  1. rovillesarate
    Member

    Hi! I tried using autoptimize to optimize wordpress css and jquery but im having conflict with the placement of the javascripts.

    The optimized javascript is automatically placed under the footer. but a gravity forms hook is inserting the custom script above the javascript. is there a way to the custom script made by gravity forms under the javascript defined by autoptimize?

    Convert This:

    <script type='text/javascript'>Gravity Forms generated custom script</script>
    <script type="text/javascript" src="http://static2.depotfashion.com.ph/wp-content/cache/autoptimize/autoptimize_59721717d6aa7f93f16d8a326e5f672d.php"></script>

    To:

    <script type="text/javascript" src="http://static2.depotfashion.com.ph/wp-content/cache/autoptimize/autoptimize_59721717d6aa7f93f16d8a326e5f672d.php"></script>
    <script type='text/javascript'>Gravity Forms generated custom script</script>

    Is there a hook to do this so it wont conflict with the javascript and to avoid having undefined javascript error?

    Posted 13 years ago on Monday June 13, 2011 | Permalink
  2. Gravity Forms scripts are output using standard WordPress hooks, not Gravity Forms hooks. They use the wp_head() and wp_footer() function calls. We don't control what order the scripts are output so i'm not entirely sure how you can control this.

    You may want to see if there is a way to exclude Gravity Forms from autooptimize. I know other minify plugins allow you to exclude certain scripts.

    Posted 13 years ago on Monday June 13, 2011 | Permalink
  3. rovillesarate
    Member

    is it possible to remove the generate script code for gravity forms? and just manually add it in my custom scripts?

    This generated script under the footer? How do i remove it from the wp_footer()?

    http://pastie.org/2070828

    Posted 13 years ago on Wednesday June 15, 2011 | Permalink
  4. rovillesarate
    Member

    is there a hook i can use to remove the generated script code from the footer?

    Posted 13 years ago on Wednesday June 15, 2011 | Permalink
  5. If you use the shortcode the script output will happen automatically.

    If you use the PHP function call to display the form, the scripts will not be output automatically and you will have to do it manually OR use the enqueue function to do it for you.

    Posted 13 years ago on Wednesday June 15, 2011 | Permalink
  6. rovillesarate
    Member

    How do i do it using the php function. I used the shortcode for the form?

    Posted 13 years ago on Thursday June 16, 2011 | Permalink
  7. That's in the documentation here.

    http://www.gravityhelp.com/documentation/page/Embedding_A_Form

    Posted 13 years ago on Thursday June 16, 2011 | Permalink