cancel
Showing results for 
Search instead for 
Did you mean: 

Scripts & Styles block causing Mixin to not load

Scripts & Styles block causing Mixin to not load

Hi everyone! This is my first time posting on the forum, thank you in advance for any replies and welcome any feedback to better align with the forum culture.

 

We have a custom Javascript mixin being loaded on one of our custom modules, this has been in place and working correctly for a while. Recently, we discovered that the Scripts and Styles block had a reference to a non-existent stylesheet in the pub directory (a Magento default?) causing a 404 so we removed it. After removing that reference, our mixin doesn't load and when we add the style tag back, the mixin loads again.

 

Is there anything about the Scripts and Styles block, how/when it's loaded, or its dependencies that would cause our mixin to not load? The adobe documentation regarding this CMS block only shares its purpose but not the way it works on the back end or what dependencies its connected to if any.

 

My steps to produce:

With the network tab open and the reference to the non-existent stylesheet still present, loading the page shows the 404 on the stylesheet and the successfully loaded mixin. After leaving the Scripts and Styles block empty and reloading the page, the 404 is gone but the mixin is not loaded.

 

What I've tried so far:

Replaced the style tag with a useless tag like <br />. This had worked for some reason a few months ago (removed the 404 and mixin loaded), but now it's not working. Tried other html tags as well.

 

Thank you!

4 REPLIES 4

Re: Scripts & Styles block causing Mixin to not load

I assume "Scripts and Styles block" in your case is some CMS block that is included somewhere and used as an admin interface to add some stylings and javascripts?

 

Have a look at the content of that block in the database itself. 

 

It's possible there are scripts / code saved in that block in the database that doesn't really load when you open the CMS block editor from the admin.

 

If that is the case, the fact that you resave the CMS block from admin probably deletes the javascript / other code that was in there in the database itself.

 

Meaning, sometimes it's possible that someone saved something into that CMS block, and that thing is in the database and that code executes when that block is called fromt he frontend, but when you open that CMS block in the admin, you don't get that code in its content so resaving it overwrites it and removes it from the databse.

Founder at https://agency418.com

Re: Scripts

Hi toniagency82ed,

Thank you for your insight! The Scripts & Style Sheets is actually a
Magento default CMS block for inserting content to the HTML Head as
described by the docs:
https://docs.magento.com/user-guide/v2.3/design/html-head.html. There was
nothing in it other than than style tag for a non-existent stylesheet and
the database also reflected this.

I think my issue is more closely associated with how mixins are loaded (or
not loaded). I found a Github issue that seems to be related:
https://github.com/magento/magento2/issues/33593.

I tried some of the solutions provided there but they didn't work. I just
commented on the issue asking for an update.

Has anyone else experienced this and found a viable workaround?

Re: Scripts

Ah... terminology differences, that is not a CMS block in Magento's terminology. CMS blocks are things you can find in admin under Content > Blocks.

 

 

Founder at https://agency418.com

Re: Scripts

Thanks for the clarification. As of now this issue is still unresolved. I posted on the Github issue asking for an update. So far we've tried several of those solutions without success, the most interesting is the one where it's suggested to load mixins.js after require-config.js by customizing the order in magento2/app/code/Magento/RequireJs/Block/Html/Head/Config.php

This actually works but our mixin is still not loaded even when mixins.js is loaded after require-config.js.

 

For now we'll wait to get a reply on the Github issue. If anyone has other insights or workarounds, we'd greatly appreciate it!