• Resolved gore.m

    (@gorem)


    Ive noticed that Woo Multilingual is loading a lot of files:

    currency-switcher-css
    dashicons-css
    wp-pointer-css
    wcml_admin-css
    cart_widget.min.js
    wcml-multi-currency.min.js
    widget.min.js
    position.min.js
    wp-pointer.min.js
    pointer.min.js

    I have language switcher combined with currency switcher, styled by my own stylesheet. So is necessary to include all files? If, no, how and which files can I dequeue?
    (Ive tried dequeue dashicons-css, but it doesnt work.)

    Thanks you

    • This topic was modified 9 years, 2 months ago by gore.m.
Viewing 12 replies - 1 through 12 (of 12 total)
  • Hello,
    Some of these files that you listed should be loaded only for the admin side of your site.
    I cannot recommend removing any of these files because it might hurt your site backend either visually or functionally and in the case for files loaded in your frontend potentially hurt your site functioning – like refreshing the cart values on changing the currency.

    Thread Starter gore.m

    (@gorem)

    Hello,
    OK, Thanks you. So… why some of these files (that shouldnt load) are loaded on frontend? (Is it bug? If I switch off Woo Multilingual, they disappear)

    Thanks you

    wcml_admin-css and dashicons-css in my opinion should have gone to the admin part only.
    I am not sure why the other files might be loading on your frontend too, I need to consult myself with our developers about this.

    I talked with one of our developers and he confirmed that some of these files should not be loaded on the frontend and that this might be a bug.
    I have escalated the issue to our developers and when I have more news about the progress, I will let you know.

    Thread Starter gore.m

    (@gorem)

    Ok, thanks you, Ill wait.

    Hello, we just released a new version – 4.1 of WooCommerce Multilingual
    That version should include a fix that prevents the loading of the unnecessary files that were loaded before.

    Thread Starter gore.m

    (@gorem)

    Hello, it is fixed!
    Now, I have:
    legacy-dropdown/style.css?ver=4.1.0′
    front-scripts.min.js?ver=4.1.0′
    cart_widget.min.js?ver=4.1.0′
    wcml-multi-currency.min.js?ver=4.1.0′

    I have one question: What about removing legacy-dropdown/style.css, cart_widget.min.js ?
    Im not using Woo Mult. css or cart widgets.

    Thanks you

    If you are not using the currency switcher you could remove leagacy-dropdown/style.css
    However, I would not advise you to remove cart_widget.js because it is related to cart fragments functions in WooCommerce and this might prevent the correct ajax updates to your cart

    Thread Starter gore.m

    (@gorem)

    Thanks you, so… how can I remove leagacy-dropdown/style.css?
    Thanks you

    Did you disable all currency switchers from the multi-currency page in WooCommerce Multilingual?
    Well I got one bug that I have just escalated to our developers.
    To work-around the issue, you need to create a new template as of ver. 4.1 WooCommerce Multilingual allows language switcher templates: https://wpml.org/documentation/related-projects/woocommerce-multilingual/designing-custom-currency-switchers-using-template-files/
    So you need to create a template without css file in your theme folder:
    \wpml\templates\currency-switchers\my-template
    config.json

    
    {
    "name":           "My custom switcher",
    }
    

    template.twig

    
    <div class="{{ css_classes }} your-custom-class" >
        <ul>
            {% for currency in currencies %}
                <li {% if( currency == selected_currency) %} class="wcml-cs-active-currency" {% endif %} >
                    <a rel="{{ currency }}">{{ get_formatted_price( currency, format )|raw }}</a>
                </li>
            {% endfor %}
        </ul>
    </div>
    

    Then you need to go to MultiCurrency tab in WooCommerce Multilingual and temporary enable Show a currency selector on the product page template and select your new custom template from the list. After this you can disable the option: Show a currency selector on the product page template
    This should make the style.css for the legacy-dropdown be disabled – because you are loading a template without .css file

    add_action( 'wp_print_styles', 'fb_woocommerce_multilingual_styles_cleaner', 100 );
    function fb_woocommerce_multilingual_styles_cleaner() {
    	wp_deregister_style( 'wcml-dropdown-0' );
    }

    I also removed this:

    function fb_woocommerce_multilingual_script_cleaner() {
    	
    	 wp_dequeue_script( 'cart-widget' );
    	 wp_dequeue_script( 'wcml-front-scripts' );
    	 wp_dequeue_script('wcml-pointer');
    	
    }
    add_action( 'wp_enqueue_scripts', 'fb_woocommerce_multilingual_script_cleaner', 99 );
    Thread Starter gore.m

    (@gorem)

    Thanks you
    Im using currency switcher (so I didnt disable it), I keep all JS, but I removed leagacy-dropdown/style.css by action from @fburatti, because I have own styling.

    What is point of this styleshet?

    Thanks you.

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Woo multilingual dequeue unnecessary files?’ is closed to new replies.