0

I just finished making a plugin but my javascript & css are being loaded into every page of the site rather than just on my admin settings page. This is the code I have in my Plugin's class:

public function onBeforeCompileHead(){
    $app = JFactory::getApplication();
        if ($app->isSite()) {
            return;
        }

    $document = JFactory::getDocument();
    $document->addScript(JUri::root() . 'plugins/system/plugin_name/js/jquery-ui.js');
    $document->addScript(JUri::root() . 'plugins/system/plugin_name/js/custom.js');
    $document->addStyleSheet(JUri::root() . 'plugins/system/plugin_name/css/style.css');

}
kyle
  • 158
  • 1
  • 1
  • 13
  • That code seems to work for me. Doesn't appear on front end, appears on plugins admin section. – RichardB May 10 '18 at 08:19
  • I would suggest to create a [custom field](https://docs.joomla.org/Creating_a_custom_form_field_type) for plugin which will only run when you go to edit page. – Irfan May 11 '18 at 05:59

0 Answers0