Removing legacy JavaScript

The LokiTheme_LumaComponents module removes legacy JavaScript for configured themes. This is done via a couple of XML layout updates (that are applied conditionally via an observer) and an observer that listens to the block event view_block_abstract_to_html_after.

Which themes are picked up by this module is determined with a DI type on the class LokiTheme\LumaComponents\Config\ThemeConfig. New themes can be added as follows:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="LokiTheme\LumaComponents\Config\ThemeConfig">
        <arguments>
            <argument name="themes" xsi:type="array">
                <item name="yireo-training-example-theme" xsi:type="string">frontend/YireoTraining/example</item>
            </argument>
        </arguments>
    </type>
</config>

JavaScript is removed by the observer \LokiTheme\LumaComponents\Observer\RemoveLegacyHtmlBindings. This class has a constructor argument patterns that contains a listing of regular expressions. These regex patterns are used to find legacy JavaScript segments in block output and replace them with nothing (so, remove it). It is probably best to keep these patterns as is, only modify them when troubleshooting things and send a PR if you think they should be changed.

The name of this module might change. Otherwise, this functionality is quite stable.

Last modified: September 16, 2025