Magento2 include external resources before local












3















I have the problem, that my external resources gets loaded after my local resources. So I can't override that styles. I have a custom theme and added a default_head_blocks.xml with the following content:



<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" src_type="url" />
<css src="css/test.css" />
</head>




Generated HTML:



<head>
...
<link rel="stylesheet" type="text/css" media="all" href="[...]/css/test.css" />
<link rel="stylesheet" type="text/css" media="all" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
...
</head>


How can I first load the external resources in my head section?










share|improve this question














bumped to the homepage by Community 12 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • what happens if you switch those lines in the xml? i.e. put the css/tests.css line before the external source?

    – Robin
    Dec 11 '15 at 10:02











  • Already tried that. Doesn't change anything. I think the order in the xml file is not relevant. But it's really weird if external resources always gets loaded after local resources...

    – Dominik Barann
    Dec 11 '15 at 10:11











  • @DominikBarann have you resolve this issue?

    – LucScu
    Jul 18 '17 at 6:55











  • @DominikBarann try to write <css src="css/test.css" media="all and (min-width: 1px)"/> and see if it helps. Atleast it helped me to put my internal themes css at the end

    – juhanix
    Dec 13 '17 at 11:34
















3















I have the problem, that my external resources gets loaded after my local resources. So I can't override that styles. I have a custom theme and added a default_head_blocks.xml with the following content:



<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" src_type="url" />
<css src="css/test.css" />
</head>




Generated HTML:



<head>
...
<link rel="stylesheet" type="text/css" media="all" href="[...]/css/test.css" />
<link rel="stylesheet" type="text/css" media="all" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
...
</head>


How can I first load the external resources in my head section?










share|improve this question














bumped to the homepage by Community 12 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • what happens if you switch those lines in the xml? i.e. put the css/tests.css line before the external source?

    – Robin
    Dec 11 '15 at 10:02











  • Already tried that. Doesn't change anything. I think the order in the xml file is not relevant. But it's really weird if external resources always gets loaded after local resources...

    – Dominik Barann
    Dec 11 '15 at 10:11











  • @DominikBarann have you resolve this issue?

    – LucScu
    Jul 18 '17 at 6:55











  • @DominikBarann try to write <css src="css/test.css" media="all and (min-width: 1px)"/> and see if it helps. Atleast it helped me to put my internal themes css at the end

    – juhanix
    Dec 13 '17 at 11:34














3












3








3


1






I have the problem, that my external resources gets loaded after my local resources. So I can't override that styles. I have a custom theme and added a default_head_blocks.xml with the following content:



<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" src_type="url" />
<css src="css/test.css" />
</head>




Generated HTML:



<head>
...
<link rel="stylesheet" type="text/css" media="all" href="[...]/css/test.css" />
<link rel="stylesheet" type="text/css" media="all" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
...
</head>


How can I first load the external resources in my head section?










share|improve this question














I have the problem, that my external resources gets loaded after my local resources. So I can't override that styles. I have a custom theme and added a default_head_blocks.xml with the following content:



<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" src_type="url" />
<css src="css/test.css" />
</head>




Generated HTML:



<head>
...
<link rel="stylesheet" type="text/css" media="all" href="[...]/css/test.css" />
<link rel="stylesheet" type="text/css" media="all" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
...
</head>


How can I first load the external resources in my head section?







magento2






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 11 '15 at 8:56









Dominik BarannDominik Barann

1861513




1861513





bumped to the homepage by Community 12 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 12 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • what happens if you switch those lines in the xml? i.e. put the css/tests.css line before the external source?

    – Robin
    Dec 11 '15 at 10:02











  • Already tried that. Doesn't change anything. I think the order in the xml file is not relevant. But it's really weird if external resources always gets loaded after local resources...

    – Dominik Barann
    Dec 11 '15 at 10:11











  • @DominikBarann have you resolve this issue?

    – LucScu
    Jul 18 '17 at 6:55











  • @DominikBarann try to write <css src="css/test.css" media="all and (min-width: 1px)"/> and see if it helps. Atleast it helped me to put my internal themes css at the end

    – juhanix
    Dec 13 '17 at 11:34



















  • what happens if you switch those lines in the xml? i.e. put the css/tests.css line before the external source?

    – Robin
    Dec 11 '15 at 10:02











  • Already tried that. Doesn't change anything. I think the order in the xml file is not relevant. But it's really weird if external resources always gets loaded after local resources...

    – Dominik Barann
    Dec 11 '15 at 10:11











  • @DominikBarann have you resolve this issue?

    – LucScu
    Jul 18 '17 at 6:55











  • @DominikBarann try to write <css src="css/test.css" media="all and (min-width: 1px)"/> and see if it helps. Atleast it helped me to put my internal themes css at the end

    – juhanix
    Dec 13 '17 at 11:34

















what happens if you switch those lines in the xml? i.e. put the css/tests.css line before the external source?

– Robin
Dec 11 '15 at 10:02





what happens if you switch those lines in the xml? i.e. put the css/tests.css line before the external source?

– Robin
Dec 11 '15 at 10:02













Already tried that. Doesn't change anything. I think the order in the xml file is not relevant. But it's really weird if external resources always gets loaded after local resources...

– Dominik Barann
Dec 11 '15 at 10:11





Already tried that. Doesn't change anything. I think the order in the xml file is not relevant. But it's really weird if external resources always gets loaded after local resources...

– Dominik Barann
Dec 11 '15 at 10:11













@DominikBarann have you resolve this issue?

– LucScu
Jul 18 '17 at 6:55





@DominikBarann have you resolve this issue?

– LucScu
Jul 18 '17 at 6:55













@DominikBarann try to write <css src="css/test.css" media="all and (min-width: 1px)"/> and see if it helps. Atleast it helped me to put my internal themes css at the end

– juhanix
Dec 13 '17 at 11:34





@DominikBarann try to write <css src="css/test.css" media="all and (min-width: 1px)"/> and see if it helps. Atleast it helped me to put my internal themes css at the end

– juhanix
Dec 13 '17 at 11:34










2 Answers
2






active

oldest

votes


















0














This issue because your module load after that module have add css file.
You need add the following code in module.xml:



    <sequence>
<module name="Magento_Theme"/>
</sequence>


This tags: Load your module before Magento_Theme module.



If you installer your module, you need find order load module in path app/etc/config.php






share|improve this answer


























  • hmm I don't think that's the problem because I load both css files in my custom theme. So the order of that both css files can't be a problem of another module?

    – Dominik Barann
    Dec 11 '15 at 9:23



















0














I have the same issue too.
I notice that only if your module is the first in app/etc/config.php magento reads correctly css sequence in head section.



I think that probably, if another module with css in head section is loaded before your module, then all modules css local resources are loaded first and css external resources are loaded all togheter after for last.



Could you try this also in your store?






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "479"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f93467%2fmagento2-include-external-resources-before-local%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    This issue because your module load after that module have add css file.
    You need add the following code in module.xml:



        <sequence>
    <module name="Magento_Theme"/>
    </sequence>


    This tags: Load your module before Magento_Theme module.



    If you installer your module, you need find order load module in path app/etc/config.php






    share|improve this answer


























    • hmm I don't think that's the problem because I load both css files in my custom theme. So the order of that both css files can't be a problem of another module?

      – Dominik Barann
      Dec 11 '15 at 9:23
















    0














    This issue because your module load after that module have add css file.
    You need add the following code in module.xml:



        <sequence>
    <module name="Magento_Theme"/>
    </sequence>


    This tags: Load your module before Magento_Theme module.



    If you installer your module, you need find order load module in path app/etc/config.php






    share|improve this answer


























    • hmm I don't think that's the problem because I load both css files in my custom theme. So the order of that both css files can't be a problem of another module?

      – Dominik Barann
      Dec 11 '15 at 9:23














    0












    0








    0







    This issue because your module load after that module have add css file.
    You need add the following code in module.xml:



        <sequence>
    <module name="Magento_Theme"/>
    </sequence>


    This tags: Load your module before Magento_Theme module.



    If you installer your module, you need find order load module in path app/etc/config.php






    share|improve this answer















    This issue because your module load after that module have add css file.
    You need add the following code in module.xml:



        <sequence>
    <module name="Magento_Theme"/>
    </sequence>


    This tags: Load your module before Magento_Theme module.



    If you installer your module, you need find order load module in path app/etc/config.php







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Dec 11 '15 at 9:17

























    answered Dec 11 '15 at 9:11









    BillBill

    2,33731239




    2,33731239













    • hmm I don't think that's the problem because I load both css files in my custom theme. So the order of that both css files can't be a problem of another module?

      – Dominik Barann
      Dec 11 '15 at 9:23



















    • hmm I don't think that's the problem because I load both css files in my custom theme. So the order of that both css files can't be a problem of another module?

      – Dominik Barann
      Dec 11 '15 at 9:23

















    hmm I don't think that's the problem because I load both css files in my custom theme. So the order of that both css files can't be a problem of another module?

    – Dominik Barann
    Dec 11 '15 at 9:23





    hmm I don't think that's the problem because I load both css files in my custom theme. So the order of that both css files can't be a problem of another module?

    – Dominik Barann
    Dec 11 '15 at 9:23













    0














    I have the same issue too.
    I notice that only if your module is the first in app/etc/config.php magento reads correctly css sequence in head section.



    I think that probably, if another module with css in head section is loaded before your module, then all modules css local resources are loaded first and css external resources are loaded all togheter after for last.



    Could you try this also in your store?






    share|improve this answer




























      0














      I have the same issue too.
      I notice that only if your module is the first in app/etc/config.php magento reads correctly css sequence in head section.



      I think that probably, if another module with css in head section is loaded before your module, then all modules css local resources are loaded first and css external resources are loaded all togheter after for last.



      Could you try this also in your store?






      share|improve this answer


























        0












        0








        0







        I have the same issue too.
        I notice that only if your module is the first in app/etc/config.php magento reads correctly css sequence in head section.



        I think that probably, if another module with css in head section is loaded before your module, then all modules css local resources are loaded first and css external resources are loaded all togheter after for last.



        Could you try this also in your store?






        share|improve this answer













        I have the same issue too.
        I notice that only if your module is the first in app/etc/config.php magento reads correctly css sequence in head section.



        I think that probably, if another module with css in head section is loaded before your module, then all modules css local resources are loaded first and css external resources are loaded all togheter after for last.



        Could you try this also in your store?







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 27 '16 at 8:43









        LucScuLucScu

        1,177928




        1,177928






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f93467%2fmagento2-include-external-resources-before-local%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Polycentropodidae

            Magento 2 Error message: Invalid state change requested

            Paulmy