cancel
Showing results for 
Search instead for 
Did you mean: 

ifconfig does not work in css/js condition in magento 2

ifconfig does not work in css/js condition in magento 2

How to use "ifconfig" conditon in magento 2 when adding css or js like magento 1.

Regards.
Dhrumin Patel


2 REPLIES 2

Re: ifconfig does not work in css/js condition in magento 2

Hello @Dhrumin

 

use require-config.js concept for that.

 

requirejs-config.jsvar config = {    paths: {            
         'myfile': "Vendor_Modulename/js/myfile"
      },   
    shim: {
    'myfile': {        deps: ['jquery']
    }
  }
} 

using,You can use anywhere in your template file by below method,

srcipt> require(["jquery","myfile"],function($,myfile){
     $(document).ready(function(){
        //call your js here...
     })
 })</script>

in above example myfile call when you instilize into phtml file

 

hope it will help you.

 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: ifconfig does not work in css/js condition in magento 2

Hello @Sunil Patel That i already know that, if i used require js way then it's load run time, but that is not solution.

I have two store english and arabic and i have one theme so just i need to load rtl css on arabic view, so i put conndition on system configuartion to if rtl css enable then load rtl css and remove default css, so how can i achive this condition in xml.

Thanks for you suggestion but it's not a solution of question.

Hope you understand my sichuation.