Add scripts and style to Joomla plugin admin settings page only

195 Views Asked by At

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');

}
0

There are 0 best solutions below