magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Remove JS loaded through RequireJS #24830

Closed bramvanderholst closed 3 years ago

bramvanderholst commented 5 years ago

Description

Due to a large amount of JS files (loaded through RequireJS) which we do not need (in our custom theme), we would like a method to remove some of these files.

This is a feature request since such functionality is not yet implemented.

Preconditions

Steps to reproduce

Expected result

Actual result

m2-assistant[bot] commented 5 years ago

Hi @bramvanderholst. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@bramvanderholst do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?


m2-assistant[bot] commented 5 years ago

Hi @danslo. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:


m2-assistant[bot] commented 5 years ago

Hi @engcom-Charlie. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

magento-engcom-team commented 5 years ago

:white_check_mark: Confirmed by @engcom-Charlie Thank you for verifying the issue. Based on the provided information internal tickets MC-21452 were created

Issue Available: @engcom-Charlie, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

m2-assistant[bot] commented 5 years ago

Hi @TadeuRodrigues. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:


m2-assistant[bot] commented 5 years ago

Hi @p-bystritsky. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:


m2-assistant[bot] commented 5 years ago

Hi @ashutoshwebkul. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:


m2-assistant[bot] commented 5 years ago

Hi @shikhamis11. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:


mrtuvn commented 4 years ago

deps is not the way to disable js. It's will include files in all page. I think we have misunderstand here and should update content in docs @bramvanderholst you should check this https://devdocs.magento.com/guides/v2.3/javascript-dev-guide/javascript/requirejs.html#requirejs-config-deps

In this snippet, the custom Vendor_Module/js/module will be loaded in all pages.

gabrieldagama commented 4 years ago

Documentation was updated and the approach that was suggested previously is not valid. Closing this issue as the problem is not actual anymore.

ericmorand commented 4 years ago

@gabrieldagama, can you please link to the documentation that explains how to remove the default JS loaded by Magento 2? I see that the issue that @bramvanderholst has been fixed since you closed it, but I can't find where is the documentation you are talking about.

Thanks by advance.

gabrieldagama commented 4 years ago

Hi @ericmorand, the issue was closed because the wrong information was removed from the devdocs, I've transformed this issue in a feature request since such functionality is yet not possible.

Thanks for highlighting it.

haxor211 commented 4 years ago

how do I remove datepicker.js, timepicker.js, spectrum.js, tinycolor.js and so on... are just a few examples. from magento 2? this useless code is just slowing down the site, all these scripts combined weight like 2 mb while my whole site is 3.5..

Come on who the hell thought its good idea to force everyone to use these javascripts??!?!?!?

haxor211 commented 4 years ago

I have found temporal solution.. disabled these useless scripts and saved like 1mb. Im on version 2.4.0

https://community.magento.com/t5/Magento-2-x-Programming/Remove-JS-files-from-beeing-loaded-through-require-js/m-p/459560/highlight/false#M11813

My shop is working fine, Im using my custom theme which inherits from luma. This feature was requested as of this writing 1 Y E A R ago.. I mean, why you(devs) are intentionally slowing people's site? These jquery ui modules should be completely optional! If anyone wants to use calendar, so be it, load it through require js whenever you need it, someone needs a COLORPICKER? sure! load it through require on product page, but no - instead all this crap is loaded site-wide slowing it down.. I mean, it should be one of the top priorities to get this fixed asap.

Speed is THE most important thing today, if your site is slow as hell because you are loading 10's of javascripts you are not using, then your SEO is bad, then you get no sales which comes to site being... useless.

I really hope this will be fixed soon and that I won't have to edit core files to remove javascript that I don't use. And don't get me started with all these big ecommerce site's that use it, because Im 100% sure their first priority is fast site.

And yes I'm mad, because I've spent few hours on such trivial thing on how to disable js I don't use...

ericmorand commented 4 years ago

@haxor211 I couldn't agree more.

haxor211 commented 4 years ago

just found out you have to leave repeat: require('knockoutjs/knockout-repeat'), fastForEach: require('knockoutjs/knockout-fast-foreach'),

Uncommented in bootstrap.php otherwise your orders won't show, dont ask me why lol

haxor211 commented 4 years ago

so the post has been removed from magento forums.. a really good way to fix your product, just remove hard questions and puff they dissapear

mrtuvn commented 4 years ago

@haxor211 i can feel your pain here This slow problem should be fix/improvement since frontend magento load too much js and make site so extreme slow for both customer and developers

mrtuvn commented 4 years ago

@ericmorand @haxor211 If you want spectrum.js, tinycolor.js load only the needed Still have PR for this Please check this https://github.com/magento/magento2/pull/28400 datepicker.js as i remember already have fix and merged in core for conditional load After this patch spectrum, tinycolor will only load when it need. Overall speed after should improved

haxor211 commented 4 years ago

@mrtuvn thats great to hear, when is the patch coming out? and what is the name? 2.4.2? tbh, all these javascripts should be loaded only when required by the "dev", for example if I want to have datepicker on site, then I load it via require or some optional magento module.. also who uses js effects (yes Im speaking about around 8js files with name effects..js) in 2020, I know not everything can be done with css, but come on...

mrtuvn commented 4 years ago

i'm not sure when it's merged Because core team must check compatible across entire eco-system b2b-modules, ee-modules, ce-modules. We could miss some testcase and make code break you can follow the PR as i mentioned in previous reply

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!

onlinebizsoft commented 3 years ago

Should be opened @mrtuvn

Paktas commented 1 year ago

So 4 years (!) after reporting this issue is still live with CE version (2.4.5-p1)