1

I am new to Joomla. I have installed a plugin and I want to overwrite the module file to remove some of the unwanted scripts.

  • project
    • modules
      • mod_modulename
        • mod_modulename.php

How can I overwrite the mod_modulename.php file?

Or is there technique by which I can remove the javascript file added by the external module?

1
  • Please earn your "informed" badge by taking the tour. Sep 25, 2019 at 7:56

2 Answers 2

4

module_name.php file can't be overridden.
Check to see if the module has options to disable the loading of its scripts - Many modules come with such settings.

If it hasn't, then you could propose this to the developers of the modules to include it in the next release.

You can always clone the module and make one of yours that will behave the way you want.

You can simply "hack" the part of the code of the module to make it work the way you want ... just remember to come back to it if you ever update it to re-do your hack.

Depending on the scripts and the way they are injected to your page by the module there are techniques where you can manage what scripts you want to keep or disable. There are for example plugins like jQuery Easy or JCC - JS CSS Control and others that allow control over which scripts are getting on the page.

Also check this Q/A for how to remove files from the head via code: Disable script loading in head

1
  • JCC - JS CSS Control did the job thanks :)
    – Ekta Puri
    Sep 25, 2019 at 23:29
-1

you could try to unset the script

$doc = JFactory::getDocument(); 
unset($doc->_scripts[JURI::root(true) . '/pathofthescript.js']);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.