Jump to main content Jump to doc navigation


This Extra was deprecated in 2021 and won't be updated further. See: github.com/Jako/AddHeaderfiles

What is AddHeaderfiles?

With this tool the MODX regClient functions are used to insert Javascript and CSS styles at the appropriate positions of the current page. Since those functions don't insert the same filename twice, the snippet could be called everywhere in the template, document or in chunks to collect all needed Javascripts and CSS styles together.

Works well with minifyRegistered.


  • MODX Revolution 2.2.x or later
  • PHP5.2 or later


It can be downloaded from within the MODX Revolution manager via Package Management, or from the MODX Extras Repository, here: https://modx.com/extras/package/addheaderfiles

Support and Bug Reporting

Forum Thread: http://forums.modx.com/thread/xxx/support-comments-for-addheaderfiles Bugtracker: https://github.com/Jako/AddHeaderfiles-revo


The snippet could be called in the page template, in the document content or in a template chunk.

Snippet parameter

Property Description Default
addcode External filenames(s) or chunkname(s) separated by &sep. The external files can have a position setting or media type separated by &sepmed. See note 1
sep Separator for files/chunknames ;
sepmed Seperator for media type or script position
mediadefault Media default for css files screen, tv, projection


Direct call



    <script type="text/javascript" src="/assets/js/jquery.js"></script>
    <link rel="stylesheet" type="text/css" href="/assets/css/colorbox.css" media="screen, tv, projection" />
    <link rel="stylesheet" type="text/css" href="/assets/css/test.css" media="print" />
    <script type="text/javascript" src="/assets/js/colorbox.js"></script>

Fill a chunk (i.e. 'headerColorbox') by:


and call it like this:


Parts of the addcode parameterchain could point to chunks too (recursive). The parts of the chunks that are not pointing to other chunks or to files/uri should contain the complete ... or ... code.



  1. If you want to insert external files with url parameters directly in the snippet call, some chars have to be masked. ? has to be masked as !q!. = has to be masked as !eq!. & has to be masked as !and!. These characters don't have to be masked in chunks.

Support the team building MODX with a monthly donation.

The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.



$0 per month—let's make that $500!

Learn more