Created
August 26, 2014 12:38
-
-
Save cameronscott137/d5004d9824b82d76e5a7 to your computer and use it in GitHub Desktop.
Gravity Forms Optimization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Gravity Forms JS */ | |
wp_deregister_script('jquery'); | |
if(!is_admin()) { | |
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js','','',true); | |
wp_enqueue_script('jquery'); | |
} | |
/* Gravity Forms Load JQuery in Footer*/ | |
function init_scripts() { | |
return true; | |
} | |
add_filter("gform_init_scripts_footer", "init_scripts"); | |
/* Gravity Forms inline JS to footer*/ | |
add_filter( 'gform_cdata_open', 'wrap_gform_cdata_open' ); | |
function wrap_gform_cdata_open( $content = '' ) { | |
$content = 'document.addEventListener( "DOMContentLoaded", function() { '; | |
return $content; | |
} | |
add_filter( 'gform_cdata_close', 'wrap_gform_cdata_close' ); | |
function wrap_gform_cdata_close( $content = '' ) { | |
$content = ' }, false );'; | |
return $content; | |
} | |
/* Gravity Forms JS */ | |
function gf_deregister() { | |
wp_deregister_script( 'gform_gravityforms' ); | |
wp_deregister_script( 'gform_json' ); | |
wp_deregister_script( 'gform_placeholder' ); | |
} | |
add_action('wp_print_styles', 'gf_deregister'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment