cancel
Showing results for 
Search instead for 
Did you mean: 

Conditional RequireJs configuration (Load requirejs-config.js programmatically?)

Conditional RequireJs configuration (Load requirejs-config.js programmatically?)

I would like to replace a `RequireJs` component only on certain conditions (for example, based on configuration). Is there any way to programmatically prevent loading of my module's `requirejs-config.js` or a different way to achieve it?

 

So, if my module is disabled from backend (configuration), then it shouldn't load RequireJs.

 

Thanks.

2 REPLIES 2

Re: Conditional RequireJs configuration (Load requirejs-config.js programmatically?)

Hi @Adarsh Khatri

 

Which magento version are you using ? because by default magento2.2.x onwards disable module functionality is not available at the backend !

 

so if you are creating a custom module with disable module functionality at backend - you will required to disabled full module - meaning if you just show/hide things when you disable/enable module then your js will surely load.

 

But if you disable your custom module from the backend - then you will required to disable it in  a magento 2's standard way like complete module disable - so in config.php as well value should change from 1 to 0.

 

then it will not load your require-js or another option would be you need to load your reqire-js on a condition bases - so only load js when you module have flag 1 (Enable module).

 

Hope it helps !

if issue solved,Click Kudos & Accept as Solution

Re: Conditional RequireJs configuration (Load requirejs-config.js programmatically?)

I am running 2.2.4 I am looking for

 

load reqire-js on a condition bases

so only load js when you module have flag 1 (Enable module).

 

How do I achieve it?