We tried enabling the built-in minification and javascript merge functions, but some functionality of third-party modules/plugins stopped working. So something is in conflict between how magento is trying to bundle/merge the files and then minify them and how the modules themselves expect the javascript to behave. The end result is, short of completely dissecting and re-building the third-party code and/or begging them to fix it, we have to disable the minification and/or the bundling to get these things to work properly or find replacements for them and go through the process of integrating, testing and replacing the functionality on our live website.

If we disable the built-in minification, the thought occurred to me that I might be able to minify individual files manually then test them individually for problems. But that would mean that either I have to modify the vendor tree in many cases (which breaks composer update capability) or find a way to override the javascript load preferences.

So how does one override what javascript is loaded? i.e. I want my version loaded instead of a module's version. Loading the other one also would not solve the problem of load times.

1 Answer 1


If I understand your question correctly, then it depends on how the vendor loads his javascript. If he uses Require.js, then create a custom module and set up your view/frontend/requires-config.js like so:

var config = {
    map: {
        '*': {
            "Vendor_Module/js/path/to/file" : 'My_Module/js/path/to/file'

If the vendor loads his javascript in head, then you can set up your module's view/frontend/layout/default.xml like so:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        <remove src="Vendor_Module::js/path/to/file.js"/>
        <script src="My_Module::js/path/to/file.js"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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