Head Remover

Creating a template starting from zero, you certainly bumped into the need to remove unused "css" or "js" that Joomla includes in the front end, the old libraries "mootools", "caption.js" or "html5fallback.js" .

Developing templates, often happen us to have to complete js libraries for a third party. These can have specific prerequisites but not always the ones that Joomla’s core offers are supported. For this reason we have to remove them manually and replace them with others thar are more suitable for the purpose

For example, when we have to develop ad hoc components, it can happen that we must use specific js libraries to manage the *front end* tasks. In order to make our website as simple as possible and avoid to add useless js to all the pages, we can do it from the inside of the component, but using the static method JDocument::addScript of the Framework. In this way the upload of the library precedes the uploading of the header libraries o_O.

For this reason we often need to add the js directly on the template index: in this way the component is deprived of one essential dependence. Furthermore, this js (unless you want to add conditional instructions to the template) will be uploaded in all the website pages, even if you don’t require it.

Unfortunately, Joomla does not support the partial override of the system classes. For this reason, make the *override* of the whole JDocument class is not easy to maintain (it will be cancelled during the first Joomla update).

We created a System plugin acting on the hook `onBeforeCompileHead() and managing its components in a more flexible way than the one that Joomla actually proposes.

This plugin can:

  • make (if requested) the unload of those files that Joomla includes by deafult; it is also possible to select them one at a time.
  • manage a list of css/js files that it is possile to download
  • manage a list of css/js files to upload respecting the prearranged order in every single pages
  • remove the tag generator if indicated, first of all for security reasons and then because it is not so good to see!
  • remove the tag author if requested
  • add more Meta Tag

We have decided to provide this plugin to the whole community because in our opinion, it can fill a cms gap. Furthermore, we would like to have a feedback from you on this question. If necessary, it is possible to create a request concerning the integration of a *dependency manager* system for the functions `JDocument::addScript()` e `JDocument::addStyleSheet(): we can consider as an example the functions that are in the Yii2 framework (if you want to have more information, here it is the link [here](http://www.yiiframework.com/doc-2.0/guide-output-client-scripts.html "here") ).

We are anxious to receive any feedback from you concerning improvements, advices or error signals.