Magento2 include external resources before local
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
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.
add a comment |
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
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
add a comment |
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
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
magento2
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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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
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
add a comment |
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?
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
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
add a comment |
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
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
add a comment |
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
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
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
add a comment |
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
add a comment |
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?
add a comment |
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?
add a comment |
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?
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?
answered Dec 27 '16 at 8:43
LucScuLucScu
1,177928
1,177928
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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