Defer Javascript - by Santhatela - on WordPress WooCommerce support

This topic has 8 replies, 2 voices, and was last updated 6 years, 4 months ago ago by Olga Barlow

  • Avatar: identidade
    Santhatela
    Participant
    July 21, 2018 at 18:38

    Hi Team

    Has there been any change in version 4.28 regarding javascripts?

    I ask why I use defer, excluding the files below for a long time with the theme:

    if (!(is_admin() )) {
    function defer_parsing_of_js ( $url ) {
    if ( FALSE === strpos( $url, ‘.js’ ) ) return $url;
    if ( strpos( $url, ‘jquery.js’ ) ) return $url;
    if ( strpos( $url, ‘jquery.min.js’ ) ) return $url;
    if ( strpos( $url, ‘head.min.js’ ) ) return $url;
    return “$url’ defer=’defer”;
    }

    But when upgrading to version 4.28, I noticed that the first image of the products in swap mode ends up going blank.

    Removing the defer everything returns to normal. I use the function because the wp rocket does not adapt well activating the defer loading

    Best regards

    Rudimar

    7 Answers
    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    July 23, 2018 at 10:45

    Hello,

    No, we did not make changes of scripts in 4.28 version of XStore theme.

    Regards

    Avatar: identidade
    Santhatela
    Participant
    August 2, 2018 at 16:13

    Thanks Olga, sorry for delay.

    I tried for a few times to go to 4.28 but the error reappeared, the store images are blank appearing only the second image of the swap when the mouse is passed.

    I’ll try again as this store is in production the time to test it is pretty limited. now running 4.27 again.

    I even saved a screen of error:

    https://ibb.co/c8XpMK

    Thanks

    Rudimar

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    August 3, 2018 at 09:56

    Hello,

    I see. It’s difficult to find out why this happened from the screenshot, maybe compatibility with some plugin that you use. You may create a staging site and provide us with access. I’ll pass it to our developers to check.

    Regards

    Avatar: identidade
    Santhatela
    Participant
    August 9, 2018 at 07:52

    Hi Olga

    I did what I could to try to isolate the problem 🙂

    I ended up isolating folders and files and I found the problem.

    It is in the file /xstore/theme/theme-setup.php

    These lines have been included and they cause the flurry of errors when using defer in wprocket or theme functions. The swap images do not appear, nor do the sliders spin.

              // Remove query string from static files
            function remove_cssjs_ver ($ src) {
     
                // Do not do it for revslider and essential-grid.
                if (strpos ($ src, ‘revslider’) || strpos ($ src, ‘essential-grid’)) return esc_url ($ src);
     
                if (strpos ($ src, ‘? ver =’))
                    $ src = remove_query_arg (‘view’, $ src);
                return esc_url ($ src);
            }
     
            add_filter (‘style_loader_src’, ‘remove_cssjs_ver’, 10, 2);
            add_filter (‘script_loader_src’, ‘remove_cssjs_ver’, 10, 2);
            
        }
    }

    So now I’m running with theme 4.28.1 and this file left the 4.27 and everything works perfectly on PHP 7.2.7 🙂

    Perhaps it would be better to leave each option to the user.

    Regards

    Rudimar

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    August 9, 2018 at 09:56

    Hello,

    I have passed your request to our developers. Maybe they will be able to solve these moments.

    Regards

    Avatar: identidade
    Santhatela
    Participant
    August 9, 2018 at 22:21

    Thanks Olga

    You are the best 🙂

    I confirm, without these lines is working fine. I using defer on functions php theme.

    Regards

    Rudimar

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    August 10, 2018 at 17:17

    Ok 😉

    Regards

  • Viewing 8 results - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.