-
Notifications
You must be signed in to change notification settings - Fork 9.4k
CSS load order incorrect using default_head_blocks.xml #1821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thank you. This issue has been reported as MAGETWO-42659 internal issue. |
Hi @chicgeek, did you find answer or workaround on the issue you reported? |
Hey @maksek, Yes, definitely a 'workaround'. If you add an attribute to the internal CSS, it will force it to parse this command after other CSS links. This attribute doesn't itself do anything. I named the attribute as follows, but it could be anything:
|
Is this still an issue? I'm wondering how I can make sure some external fonts get loaded before the regular style-m.css and style-l.css files. |
@jahvi Did you see the workaround I posted just above your comment? Have you tried this, or do all CSS instructions get loaded before your fonts? Alternately, the |
@chicgeek It does work for 'new' stylesheets but if they've been registered in the parent theme like This extension seems to work but I haven't tested it throughly: |
It looks like Magento separates the assets into 'groups' before rendering them into the page like, css, scripts, link, etc. You can order the assets within each group using @chicgeek's technique or the extension mentioned above but it doesn't seem like it's possible to load one group before another so if you want to load some google fonts before everything else you'll need to rewrite this functionality. In my case I ended up copying the |
I've got the same problem, while trying to load Google Fonts (via CDN) before a custom CSS file which has the font-family. But Magento does the reverse so that the font won't work. I'm using Magento 2.1.2. Is there an upcoming fix for this? |
Waiting for this to get sorted out. |
#distributed-cd |
@SergeyDmitruk thank you for joining. Please accept team invitation here and self-assign the issue. |
Hi @chicgeek. Thank you for your report. The fix will be available with the upcoming 2.2.5 release. |
Added new attribute 'order' for set loading order . Those attribute resolve issue about render files for some order.
…agento#1821 (cherry picked from commit 51c78b9)
…agento#1821 (cherry picked from commit 21cb3af)
…agento#1821 (cherry picked from commit ad82a7a)
Hi @chicgeek. Thank you for your report. The fix will be available with the upcoming 2.3.0 release. |
@ishakhsuvarov - Can you confirm if this also affects other filetypes or only CSS? |
@BenSpace48 Looking at the committed changes it looks like all the nodes are ordered and then outputted so it should affect all types. |
@magento-engcom-team it is not working for <script> tags in default.xml |
Does not work. How can I load bootstrap first? |
@Eddcapone Did you try the workaround? (Note: I've not tried this recently.) |
The workaround shows how to load a script last, but I need my bootstrap script loaded before style-m.css and style-l.css. Otherwise it will override some stuff, e.g. it changes the color of a tag to blue. |
is not working as expected. please fix it |
This is not fixed. And I'm developing a site on Magento 2.3.4.
I can confirm that this workaround does fix the issue however, thanks @chicgeek 👍 |
Still not fixed in magento 2.3.5 ? Please reopen the issue. |
For my theme I am loading in two stylesheets: one from a CDN (
cdn.css
) and one from my theme (local.css
). They should be loaded in this order in the DOM but it does not preserve the order indicated by the XML.This is what I have in
default_head_blocks.xml
in the correct order:But in the DOM it does not load in this order:
local.css
is loaded in first andcdn.css
second.I believe this to be a bug - am I missing additional configuration to set load order for these assets?
I did not find information specific to load order in the documentation. I know in M1 the order specified in the XML would be preserved in the DOM.
The text was updated successfully, but these errors were encountered: