Magento 1.9 – Fix for CSS File Loading Too Early

csslayoutmagento-1.9

I am loading a CSS file via the local.xml this way:

<?xml version="1.0"?>

    <layout>
        <default>
            <reference name="head">
                <action method="removeItem"><type>skin_css</type><name>css/style.css</name></action>
                <action method="addItem"><type>skin_css</type><name>css/style.css</name></action>
            </reference>
        </default>
    </layout>

Only problem is that this file is loaded almost at the beginning of the head. How do I get this file, to be loaded at the end of the header?

Best Answer

A colleague of mine has found a better solution, so I will post it here:

It seems that Magento 1.9 loads CSS files only last, when they contain an if statement. Instead of the code I used in the local.xml file, he replaced it with this:

   <action method="addItem">
        <type>skin_css</type>
        <name>css/style.css</name>
        <params/>
        <if><![CDATA[<!--[]><!-->]]></if>
    </action>
Related Topic