Magento2 Remove JS from Homepage
-
07-02-2021 - |
Pergunta
In my website homepage there are multiple bundle js
<script type="text/javascript" src="https://website.com/static/version1545621016/frontend/website/default/fr_FR/js/bundle/bundle0.min.js"></script>
<script type="text/javascript" src="https://website.com/static/version1545621016/frontend/website/default/fr_FR/js/bundle/bundle1.min.js"></script>
<script type="text/javascript" src="https://website.com/static/version1545621016/frontend/website/default/fr_FR/js/bundle/bundle2.min.js"></script>
<script type="text/javascript" src="https://website.com/static/version1545621016/frontend/website/default/fr_FR/js/bundle/bundle3.min.js"></script>
<script type="text/javascript" src="https://website.com/static/version1545621016/frontend/website/default/fr_FR/js/bundle/bundle4.min.js"></script>
<script type="text/javascript" src="https://website.com/static/version1545621016/frontend/website/default/fr_FR/js/bundle/bundle5.min.js"></script>
why all are there?I want to remove it for homepage
Solução
Turn off JS bundling in the admin Stores > Configuration > Advanced > Developer
(Developer mode) or via CLI if you're in Production mode:
php -f bin/magento config:set dev/js/enable_js_bundling 1
With JS bundling enabled Magento takes a big performance hit. Inchoo did a post that illustrated this well - https://inchoo.net/magento-2/javascript-bundling-magento-2/
Outras dicas
make a change xml file in a your theme
app/design/frontend/website/default/Magento_Theme/layout/cms_index_index.xml
Content file cms_index_index.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<remove src="js/bundle/bundle0.js"/>
</head>
</page>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange