Support » Theme: Astra » Loading jquery

  • john53

    (@john53)


    Hi
    I get the following error when running chrome lighthouse performance audit:-

    “Uncaught ReferenceError: jQuery is not defined
    at (index):728”

    I saw a reply to another user who had the same problem. Your reply was:-
    “If you are adding custom JS based on jQuery, you will have to include jQuery from your child theme.

    wp_enqueue_script( ‘jquery’ );

    adding this line in your script enqueue function will load jQuery.”

    I dont understand what to do. Do I add this line to functions.php of my child theme?

    Can you please give me details of what to do because I am not an expert at this type of thing?

    For your referenceI have copied and pasted my functions.php for child theme below:-

    <?php
    /**
    * Astra Child Theme functions and definitions
    *
    * @link https://developer.wordpress.org/themes/basics/theme-functions/
    *
    * @package Astra Child
    * @since 1.0.0
    */

    /**
    * Define Constants
    */
    define( ‘CHILD_THEME_ASTRA_CHILD_VERSION’, ‘1.0.0’ );

    /**
    * Enqueue styles
    */
    function child_enqueue_styles() {

    wp_enqueue_style( ‘astra-child-theme-css’, get_stylesheet_directory_uri() . ‘/style.css’, array(‘astra-theme-css’), CHILD_THEME_ASTRA_CHILD_VERSION, ‘all’ );

    }
    add_filter( ‘term_description’, ‘do_shortcode’ );
    add_action( ‘wp_enqueue_scripts’, ‘child_enqueue_styles’, 15 );
    add_filter( ‘astra_enable_default_fonts’, ‘__return_false’ );

    Thank you

    Best regards

    John

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • john53

    (@john53)

    The error appears to be caused by Astra Widget social profiles:-

    This is the line referred to:-

    “#astra-widget-social-profiles-20 .astra-widget-social-profiles-inner.icon-official-color.simple li .twitter.ast-widget-icon svg{fill:#55acee;}#astra-widget-social-profiles-20 .astra-widget-social-profiles-inner.icon-official-color li .twitter.ast-widget-icon svg{fill:#ffffff;}#astra-widget-social-profiles-20 .astra-widget-social-profiles-inner.icon-official-color.circle li .twitter.ast-widget-icon, #astra-widget-social-profiles-20.astra-widget-social-profiles-inner.icon-official-color.square li .twitter.ast-widget-icon{background-color:#55acee;}#astra-widget-social-profiles-20 .astra-widget-social-profiles-inner.icon-official-color.square-outline li .twitter.ast-widget-icon svg,#astra-widget-social-profiles-20 .astra-widget-social-profiles-inner.icon-official-color.circle-outline li .twitter.ast-widget-icon svg{fill:#55acee;}#astra-widget-social-profiles-20 .astra-widget-social-profiles-inner.icon-official-color.square-outline li .twitter.ast-widget-icon, #astra-widget-social-profiles-20 .astra-widget-social-profiles-inner.icon-official-color.circle-outline li .twitter.ast-widget-icon{border-color:#55acee;}#astra-widget-social-profiles-20 .astra-widget-social-profiles-inner .ast-widget-icon{font-size:40px;}#astra-widget-social-profiles-20 .astra-widget-social-profiles-inner.circle li .ast-widget-icon, #astra-widget-social-profiles-20 .astra-widget-social-profiles-inner.circle-outline li .ast-widget-icon{font-size:40px;}#astra-widget-social-profiles-20 .astra-widget-social-profiles-inner li > a .ast-widget-icon{margin-right:px;}#astra-widget-social-profiles-20 .astra-widget-social-profiles-inner li > a {padding-bottom:px;}#astra-widget-social-profiles-20 .astra-widget-social-profiles-inner li:last-child a{margin-right:0;padding-bottom:0;}</style> <script type=’text/javascript’>/* <![CDATA[ */ var astra = {“break_point”:”600″,”isRtl”:””}; /* ]]> */</script> <script>/(trident|msie)/i.test(navigator.userAgent)&&document.getElementById&&window.addEventListener&&window.addEventListener(“hashchange”,function(){var t,e=location.hash.substring(1);/^[A-z0-9_-]+$/.test(e)&&(t=document.getElementById(e))&&(/^(?:a|select|input|button|textarea)$/i.test(t.tagName)||(t.tabIndex=-1),t.focus())},!1);</script> <script type=”text/javascript”>var to_like_post = {“url”:”https://www.primaflorafloristaccrington.co.uk/wp-admin/admin-ajax.php”,”nonce”:”1465f29889″};!function(t){“use strict”;t(document).ready(function(){t(document).on(“click”,”.to-post-like:not(‘.to-post-like-unactive’)”,function(e){e.preventDefault();var o=t(this),n=o.data(“post-id”),s=parseInt(o.find(“.to-like-count”).text());return o.addClass(“heart-pulse”),t.ajax({type:”post”,url:to_like_post.url,data:{nonce:to_like_post.nonce,action:”to_like_post”,post_id:n,like_nb:s},context:o,success:function(e){e&&((o=t(this)).attr(“title”,e.title),o.find(“.to-like-count”).text(e.count),o.removeClass(e.remove_class+” heart-pulse”).addClass(e.add_class))}}),!1})})}(jQuery);</script><script>window.lazyLoadOptions = {

    john53

    (@john53)

    When I deactivate astra widgets the problem moves onto another astra css

    This becomes the problem line now:-

    “}</style><script type=’text/javascript’>/* <![CDATA[ */ var astra = {“break_point”:”600″,”isRtl”:””}; /* ]]> */</script> <script>/(trident|msie)/i.test(navigator.userAgent)&&document.getElementById&&window.addEventListener&&window.addEventListener(“hashchange”,function(){var t,e=location.hash.substring(1);/^[A-z0-9_-]+$/.test(e)&&(t=document.getElementById(e))&&(/^(?:a|select|input|button|textarea)$/i.test(t.tagName)||(t.tabIndex=-1),t.focus())},!1);</script> <script type=”text/javascript”>var to_like_post = {“url”:”https://www.primaflorafloristaccrington.co.uk/wp-admin/admin-ajax.php”,”nonce”:”1465f29889″};!function(t){“use strict”;t(document).ready(function(){t(document).on(“click”,”.to-post-like:not(‘.to-post-like-unactive’)”,function(e){e.preventDefault();var o=t(this),n=o.data(“post-id”),s=parseInt(o.find(“.to-like-count”).text());return o.addClass(“heart-pulse”),t.ajax({type:”post”,url:to_like_post.url,data:{nonce:to_like_post.nonce,action:”to_like_post”,post_id:n,like_nb:s},context:o,success:function(e){e&&((o=t(this)).attr(“title”,e.title),o.find(“.to-like-count”).text(e.count),o.removeClass(e.remove_class+” heart-pulse”).addClass(e.add_class))}}),!1})})}(jQuery);</script><script>window.lazyLoadOptions = {

    This error is categorised as critical.
    Any help much appreciated.

    Best regards
    John

    Hi @john53 ,

    It seems a bit weird issue which needs debugging. Would you mind opening a support ticket to that we can have a proper look at your problem?

    Regards,
    Deepak

    Hi

    Thank you very much. I will open a support ticket.

    Best regards

    John

    Hi @john53 ,

    I see that you have opened a ticket with us and we have already responded to it. Could you please check your inbox and reply so that we can help you further?

    Regards,
    Deepak

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.