Mustaghees Mustaghees - 4 months ago 31
Smarty Question

Move CSS resources from head to footer in prestashop

I want to remove all CSS(and JS) resources from

<head>
to footer in Prestashop. But I can't figure it out, even after a lot of experimenting. Each time I change something their is an unexpected result.

I tried editing
displayHeader()
and
displayFooter()
in FrontController.php in classes, and also
header.tpl
and
footer.tpl
in
themes/prestashop
folder.

I guess I can't figure out the right way to do it. I have also tried googling. Any help?

Note: I only have FTP access to files.

Answer

In PS 1.6 you can already move JS at the end with this option in "Advanced Parameters -> Performance"

enter image description here

If you want to move CSS you can move this code from /themes/your-theme/header.tpl to footer.tpl:

{if isset($css_files)}
    {foreach from=$css_files key=css_uri item=media}
        {if $css_uri == 'lteIE9'}
            <!--[if lte IE 9]>
            {foreach from=$css_files[$css_uri] key=css_uriie9 item=mediaie9}
            <link rel="stylesheet" href="{$css_uriie9|escape:'html':'UTF-8'}" type="text/css" media="{$mediaie9|escape:'html':'UTF-8'}" />
            {/foreach}
            <![endif]-->
        {else}
            <link rel="stylesheet" href="{$css_uri|escape:'html':'UTF-8'}" type="text/css" media="{$media|escape:'html':'UTF-8'}" />
        {/if}
    {/foreach}
{/if}
Comments