cancel
Showing results for 
Search instead for 
Did you mean: 

Adding JavaScript file

Adding JavaScript file

I am developing a module. I am new in module development. 

Now I need to know how to add JavaScript file when someone developing a module ??

The conditions are as below:

 

1. When the module installed then the JavaScript file will be loaded.

2. When the module uninstalled then the JavaScript file will be not loaded.

3. When the module disabled through XML file of app/etc/modules directory then the JavaScript file will be not loaded.

4. When the module disabled through enable/disable option of the module then the JavaScript file will be not loaded.

 

Thanks

3 REPLIES 3

Re: Adding JavaScript file

  1. If your module is installed and the javascript is part of the module then your JS gets loaded (unless 4. has conditions).
  2. If your module is NOT installed, then there's no JS to be loaded.
  3. If your module is disabled from bootstrap XML, then your javascript do not get loaded as the layout xml that loads it do not get loaded either.
  4. There's an ifconfig attrbute to achieve it. Check out this page: http://magento.stackexchange.com/questions/3418/conditionally-show-hide-blocks-in-layout-xml

 

Tanel Raja

Re: Adding JavaScript file

Thanks @Pronto for your reply. But how to add Js file to meet your Answer 

 

Thanks

Re: Adding JavaScript file

When you create your own extension one thing you want to do is to declare a layout file. In the layout file you can define layout updates, such as additional JS/CSS files to be loaded. The page I linked explains some of those things.

Tanel Raja