Question

Inevitably, I'm trying to improve our Magento 2.3.0 Pagespeed score. Most of the damage is being done by the excess of unneeded/unwanted js files.

Is there any simple way to remove js such as calendar.js, tooltip.js etc? It appears tooltip.js is loaded by jquery-ui.js but I can't find where calendar is loaded using grep, any suggestions please?

I expect deleting/renaming the unwanted js files will result in errors at best and a non functioning website at worst? Thanks

No correct solution

OTHER TIPS

  1. In your layout file you can define to remove the js that is not required..
    This blog can help you in doing this
    https://meetanshi.com/blog/remove-js-and-css-in-magento-2-using-layout-xml/#:~:text=Programmatic%20Solution%20to%20Remove%20JS,to%20remove%20JavaScript%20and%20CSS.
  2. This thread may help you
    https://community.magento.com/t5/Magento-1-x-Programming/How-to-remove-js-files/td-p/48294#:~:text=To%20remove%20js%20file%20you,template%20file%20of%20that%20page.
  3. Adding some code snippet so that you can understand easily
    After we override magento 2 customer module this is the path
    app/design/frontend/Raptor/Desktop/Magento_Customer/layout/customer_account.xml
    <?xml version="1.0"?>
    <!--
    /**
     * Copyright © Magento, Inc. All rights reserved.
     * See COPYING.txt for license details.
*/
/* M241= *PROGRAMMER - Vibhore *PURPOSE - UserDashboard */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Customer My Account (All Pages)" design_abstraction="custom">
<head>
 <title>My Account</title>
 <remove src="js/tracking.js"/> 
 <remove src="js/tracking.min.js"/>
 <remove src="css/calendar.css"/>
 <remove src="css/calendar.min.css"/>
 <remove src="mage/calendar.css"/>
 <remove src="mage/calendar.min.css"/>
 <!--<remove src="css/styles-m.css"/>-->
 <remove src="css/header-footer.css"/>
 <remove src="css/header-footer.min.css"/>
 <remove src="css/style.css"/>
 <remove src="css/style.min.css"/>
 <remove src="css/brand.css"/>
 <remove src="css/brand.min.css"/>
 <remove src="fonts/font.css"/>
 <remove src="fonts/font.min.css"/>
 <remove src="css/owl.carousel.css"/>
 <remove src="css/owl.carousel.min.css"/>
 <remove src="css/owl.theme.green.css"/>
 <remove src="css/owl.theme.green.min.css"/>
 <!--<remove src="css/styles-l.css"/>-->
 <remove src="css/print.css"/>
 <remove src="css/print.min.css"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top