---
title: "Remove CSS and Scripts in Joomla - Tassos Code Snippets"
description: "There are cases where you would like to remove or disable unnecessary CSS and JavaScript files from your Joomla site output. This is a common task: re"
url: "https://www.tassos.gr/docs/tassos-code-snippets/howto/performance-system/remove-css-js-joomla"
date: "2026-04-05T04:08:14+00:00"
language: "en-GB"
---

[ Home ](https://www.tassos.gr/index.php?option=com_content&view=category&layout=blog&id=24&Itemid=1088) / [ Tassos Code Snippets ](https://www.tassos.gr/index.php?option=com_content&view=category&id=120) / [ How-to Guides ](https://www.tassos.gr/index.php?option=com_content&view=category&id=125) / [ Performance &amp; System ](https://www.tassos.gr/index.php?option=com_content&view=category&id=145)

#  Remove CSS and Scripts in Joomla

There are cases where you would like to remove or disable unnecessary CSS and JavaScript files from your Joomla site output. This is a common task: removing styles and scripts to improve performance, avoid file conflicts, and keep pages lighter. Hopefully, you don't need an extra plugin. You can do it with Tassos Code Snippets using a simple PHP snippet.

## [The PHP Snippet Code](#the-php-snippet-code)

This code removes specific CSS and JS assets before Joomla renders the `<head>` section, so you can safely control which files are loaded on your frontend pages.

 ```
use Joomla\CMS\Factory;

// Edit these asset names.
$unwantedcss = [
    'bootstrap.css',
    'template.custom',
];

$unwantedjs = [
    'jquery',
    'core',
];

// Do not edit below.
$app = Factory::getApplication();

$app->registerEvent('onBeforeCompileHead', function() use ($app, $unwantedcss, $unwantedjs)
{
    $document = $app->getDocument();

    if (!$document || $document->getType() !== 'html')
    {
        return;
    }

    $wa = $document->getWebAssetManager();

    $styles = array_filter(array_map('trim', $unwantedcss));

    foreach ($styles as $style)
    {
        if ($wa->assetExists('style', $style))
        {
            $wa->disableAsset('style', $style);
        }
    }

    $scripts = array_filter(array_map('trim', $unwantedjs));

    foreach ($scripts as $script)
    {
        if ($wa->assetExists('script', $script))
        {
            $wa->disableAsset('script', $script);
        }
    }
});
```

## [How to add this snippet](#how-to-add-this-snippet)

1. Install [Tassos Code Snippets](https://www.tassos.gr/docs/tassos-code-snippets/getting-started/how-to-install) if it is not installed already.
2. Go to your Joomla Administrator area.
3. Open **Components** -&gt; **Tassos Code Snippets**.
4. Click **New**.
5. Select **PHP** as the snippet type.
6. Paste the remove styles and scripts code above.
7. Select **Insertion Method** -&gt; **Page Load**.
8. Publish the snippet.
9. Optionally, open the **Conditional Logic** tab to restrict which pages or users the snippet runs on. Leave it empty to run it site-wide. Learn more in [Using Snippet Logic](https://www.tassos.gr/docs/tassos-code-snippets/functionality/conditional-logic).

Congratulations! You've just added the ability to remove CSS and JS in Joomla without installing another plugin or adding unnecessary bloat to your site. To learn more details, visit the [PHP Snippet](https://www.tassos.gr/docs/tassos-code-snippets/types/php) documentation: [ ](https://www.tassos.gr/docs/tassos-code-snippets/types/php)

## [Use Cases](#use-cases)

- Remove legacy MooTools files not used anymore
- Remove duplicate Bootstrap CSS/JS loaded by multiple extensions
- Prevent conflicting libraries from loading together
- Improve page speed by reducing unnecessary requests
- Keep frontend asset output cleaner on selected pages

 Last updated on Mar 19th 2026 13:03

## Schema

```json
{
    "@context": "https://schema.org",
    "@type": "BreadcrumbList",
    "itemListElement": [
        {
            "@type": "ListItem",
            "position": 1,
            "name": "Home",
            "item": "https://www.tassos.gr"
        },
        {
            "@type": "ListItem",
            "position": 2,
            "name": "Home",
            "item": "https://www.tassos.gr/docs"
        },
        {
            "@type": "ListItem",
            "position": 3,
            "name": "Tassos Code Snippets",
            "item": "https://www.tassos.gr/docs/tassos-code-snippets"
        },
        {
            "@type": "ListItem",
            "position": 4,
            "name": "How-to Guides",
            "item": "https://www.tassos.gr/docs/tassos-code-snippets/howto"
        },
        {
            "@type": "ListItem",
            "position": 5,
            "name": "Performance & System",
            "item": "https://www.tassos.gr/docs/tassos-code-snippets/howto/performance-system"
        },
        {
            "@type": "ListItem",
            "position": 6,
            "name": "Remove CSS and Scripts in Joomla",
            "item": "https://www.tassos.gr/docs/tassos-code-snippets/howto/performance-system/remove-css-js-joomla"
        }
    ]
}
```

```json
{
    "@context": "https://schema.org",
    "@type": "Article",
    "mainEntityOfPage": {
        "@type": "WebPage",
        "@id": "https://www.tassos.gr/docs/tassos-code-snippets/howto/performance-system/remove-css-js-joomla"
    },
    "headline": "Remove CSS and Scripts in Joomla",
    "image": {
        "@type": "ImageObject",
        "url": "https://www.tassos.gr/"
    },
    "publisher": {
        "@type": "Organization",
        "name": "Tassos",
        "logo": {
            "@type": "ImageObject",
            "url": "https://www.tassos.gr/https://www.tassos.gr/media/brand/logo-text.png"
        }
    },
    "author": {
        "@type": "Person",
        "name": "Tassos Marinos",
        "url": "https://www.tassos.gr/docs/tassos-code-snippets/howto/performance-system/remove-css-js-joomla"
    },
    "datePublished": "2026-03-09T15:14:26+02:00",
    "dateCreated": "2026-03-09T15:14:26+02:00",
    "dateModified": "2026-03-19T13:58:56+02:00"
}
```
