Support » Plugin: Genesis Simple Share » Uncaught ReferenceError: jQuery is not defined
Uncaught ReferenceError: jQuery is not defined
-
Hi, your plugin dont work with jquery from google cdn, apperas this:
Uncaught ReferenceError: jQuery is not defined in line 72
<script type=’text/javascript’>
line 72: jQuery(document).ready(function($) {
$(‘#googleplus-after-38’).sharrre({How can fixed??
-
Hi, Mauricio.
Can you share a link to a page that displays this error, please? It sounds like there may be two versions of jQuery included on the page.
Hi, Nick
Please see any single post in getmovil this warning appears in code source, right now i have mashare plugin to share my single post, but with o without another social sharing plugin, Genesis Simple Share dont work.
Thanks for you great support.
Looks like WP deferred javaScript plugin cause the error, the same bug appears when i use jquery from google cdn in async o defer mode, how can fixed??
Thanks for mentioning that you’re loading jQuery with the defer attribute, Mauricio. That sheds new light on this.
The error is appearing because the plugin’s inline script will be loaded before jQuery. To work around this, you could defer loading of inline scripts by removing them and adding them after jQuery has loaded. One way to do that is to add this code to your active theme’s functions.php file:
add_action( 'after_setup_theme', 'defer_genesis_responsive_slider', 16 ); function defer_genesis_responsive_slider() { remove_action( 'wp_footer', 'genesis_responsive_slider_flexslider_params' ); add_action( 'wp_footer', 'custom_genesis_responsive_slider_flexslider_params' ); } function custom_genesis_responsive_slider_flexslider_params() { $timer = ( int ) genesis_get_responsive_slider_option( 'slideshow_timer' ); $duration = ( int ) genesis_get_responsive_slider_option( 'slideshow_delay' ); $effect = genesis_get_responsive_slider_option( 'slideshow_effect' ); $controlnav = genesis_get_responsive_slider_option( 'slideshow_pager' ); $directionnav = genesis_get_responsive_slider_option( 'slideshow_arrows' ); $output = 'function sliderDefer(method) { if (window.jQuery) method(); else setTimeout(function() { sliderDefer(method) }, 50); } function sliderParams(){ jQuery(document).ready(function($) { $(".flexslider").flexslider({ controlsContainer: "#genesis-responsive-slider", animation: "' . esc_js( $effect ) . '", directionNav: ' . $directionnav . ', controlNav: ' . $controlnav . ', animationDuration: ' . $duration . ', slideshowSpeed: ' . $timer . ' }); }); } sliderDefer( sliderParams ); '; $output = str_replace( array( "\n", "\t", "\r" ), '', $output ); echo '<script type=\'text/javascript\'>' . $output . '</script>'; }
That will defer loading of the inline slider script until after jQuery is loaded, and should prevent the error you were seeing.
Hi, thanks for you support.
With your code appears this warning:
Fatal error: Call to undefined function genesis_get_responsive_slider_option() in C:\xampp\htdocs\blog\wp-content\themes\getmovil\functions.php on line 129
Line 129: $timer = ( int ) genesis_get_responsive_slider_option( ‘slideshow_timer’ );
In my child theme i dont use genesis responsive slider or responsive_slider_flexslider or superfish, i have this in my functions.php:
//* Enqueue Scripts and Styles add_action( 'wp_enqueue_scripts', 'getmovil_enqueue_scripts_styles' ); function getmovil_enqueue_scripts_styles() { wp_enqueue_script( 'getmovil-responsive-menu', get_stylesheet_directory_uri() . '/js/responsive-menu.js', array( 'jquery' ), '1.0.0', true ); $output = array( 'mainMenu' => __( 'Menu', 'getmovil' ), 'subMenu' => __( 'Menu', 'getmovil' ), ); wp_localize_script( 'getmovil-responsive-menu', 'getmovilL10n', $output ); } // Remove jQuery Migrate Script from header and Load jQuery from Google API function crunchify_remove_jquery_migrate_load_google_hosted_jquery() { if (!is_admin()) { wp_deregister_script('jquery'); wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.12.3/jquery.min.js', false, null); wp_enqueue_script('jquery'); } } add_action('init', 'crunchify_remove_jquery_migrate_load_google_hosted_jquery');
Best regards.
Edit: Sorry, Mauricio – I cross-posted my original suggestion on the wrong plugin board.
I’ll take a look at Simple Share and async loading shortly…
Hi, with your new code, dont appears any warning, but appears the same error in chrome console:
localhost/:76 Uncaught ReferenceError: jQuery is not defined
Line 76: jQuery(document).ready(function($) {
I dont use Responsive Slider plugin.
Thanks for you support.
Unfortunately there is not a simple way to delay loading of inline scripts with Genesis Simple Share to account for deferred loading of jQuery. (It is possible, but would require editing the plugin.)
Your best options are to either:
- load jQuery without the defer attribute
- use a share plugin that does not require JavaScript, such as https://wordpress.org/plugins/fast-social-share-buttons/ or https://wordpress.org/plugins/naked-social-share/screenshots/ (with “disable JavaScript” enabled in the plugin’s options).
(Sorry for the confusion, Mauricio – I originally thought this topic was posted in the Genesis Responsive Slider forum.)
- The topic ‘Uncaught ReferenceError: jQuery is not defined’ is closed to new replies.