Friday, September 13, 2013

Recently (version 3.6) we moved all JS files to the end of <body>, this improves performance but there are some cases where you as a developer need to put JS files in <head>, in 3.7 we are introducing a way to do this, from a controller you can now do this:

<?php
$this->template()->setHeader('head', array(
    'somefile.js' => 'static_script',
    'otherfile.js' => 'style_script'
));
And it will be loaded in the head. Notice that the difference is the first param when calling ->setHeader.

1 comment:

  1. Thank you!

    Just another notes regarding.

    Before we can decide which file compress and which not, using 'cache' togheter with setHeader as first parameter.

    Some javascript file stop working when compressed, so it should not be compressed, I see that you disable for example tinymce to be compressed.

    How we can do this in 3.7?

    Thanks!

    ReplyDelete