0

I have read

this https://github.com/magento/magento2/issues/5835

and this Exclude custommodule Js from minification of Js in Magento2

and this https://github.com/magento/magento2/pull/13687

and I still don't know how to modify config.xml to exclude 3rd party .js

The module is from an extension by Mageplaza https://www.mageplaza.com/magento-2-social-share/

error

The code I add to the module config.xml is

        <dev>
            <js>
                <minify_exclude>
                    <config>https://static.addtoany.com/menu/page.js</config>
                </minify_exclude>
            </js>
        </dev>
1

Paste this after

<default>

in config.xml

    <dev>
        <js>
            <minify_exclude>
                <mpsocialshare>https://static.addtoany.com/menu/page.js
                </mpsocialshare>
            </minify_exclude>
        </js>
    </dev>
  • You are right. Just to be clearer, I included a full answer as to why it initially won't work. – wltprgm Jul 28 '19 at 10:36
0

A full answer, all steps below should be done accordingly:

  1. Modify the module's config.xml, with the following:
<config>
    <default>
        <dev>
          <js>
            <minify_exclude>
              <social_share>
                https://static.addtoany.com/menu/page.js
              </social_share>
            </minify_exclude>
          </js>
        </dev>
    </default>
</config>
  1. remove all relevant requirejs-min-resolver.min.js in pub/static/, for example:
rm pub/static/frontend/Magento/luma/en_US/requirejs-min-resolver.min.js
  1. Flush layout cache
bin/magento cache:flush layout
  1. Redeploy
bin/magento setup:static-content:deploy en_US -a frontend -t Magento/luma

note ,after this step, you can check the before and after difference in pub/static/frontend/Magento/luma/en_US/requirejs-min-resolver.min.js

  1. curl or browse your website in a browser for new cached merged minified .js and .css files
curl -Lo test.html localhost:/magento

from what I test, you don't have to flush full_page, it will generate new .js and .css file nonetheless

I have to be specifc, since we are on production mode, clearing everything in generated/, pub/static/ and var/ will be a waste of time to wait for deployment.

0

You need to update the config.xml file of the custom extension (app/code/Vendor/Extension/etc/config.xml).

Paste the following code in the default tag in config.xml

<dev>
    <js>
        <minify_exclude>
            <mpsocialshare>\.addtoany\.com/menu/</mpsocialshare>
        </minify_exclude>
    </js>
</dev>

I suppose to create/update the extension: Endertech_Cms.

So create the files:

  1. app/code/Endertech/Cms/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Endertech_Cms',
    __DIR__
);
  1. app/code/Endertech/Cms/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Endertech_Cms" setup_version="1.1.0">
        <sequence>
            <!-- Endertech Cms needs Magento CMS to be loaded? -->
            <module name="Magento_Cms" />
        </sequence>
    </module>
</config>
  1. app/code/Endertech/Cms/etc/config.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <dev>
            <js>
                <minify_exclude>
                    <mpsocialshare>\.addtoany\.com/menu/</mpsocialshare>
                </minify_exclude>
            </js>
        </dev>
    </default>
</config>

Run the following commands to deploy:

rm -rf var/di/* var/generation/* var/cache/* var/view_preprocessed/*
php -d memory_limit=-1 bin/magento setup:upgrade
php -d memory_limit=-1 bin/magento setup:di:compile
php -d memory_limit=-1 bin/magento setup:static-content:deploy -f
php -d memory_limit=-1 bin/magento cache:clean

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.