In the realm of plugins, each one has the power to dictate which assets are loaded with each page request. However, there is an opportunity for you to craft your own plugin that adheres to your unique logic and can eliminate certain assets before the page is displayed (consider utilizing the ipBeforeController
event for this purpose). The designation of _1
signifies a low priority level, ensuring that your script will be executed last in the sequence.
class Event
{
public static function ipBeforeController_1()
{
// Retrieve all JavaScript files that have been added
$allJs = \Ip\ServiceLocator::pageAssets()->getJavascript();
// ... insert your custom logic here ...
// Remove specific file
\Ip\ServiceLocator::pageAssets()->removeJavascript($fileName);
}
}