Assets to hidden modules still enqueued

I was creating a more of a global module for our customers, and was about to migrate over to the new module, and was for some reason getting a javascript error that came from a module that was hidden. I then started to look abit deeper into this and found out that if you set the visibility for a module to “hidden” in (on the visibility_display settings field) the assets like css and js still looks to be enqueued in the bundle file.

I tried this multiple times and also checked how the frontend.x.php files are enqueued and i couldn’t find anything on them that checks for the visibility of the modules etc.

I made little walkthrough on how to check this, for this I used the post grid and set it to never show.

(this is my first post so I could only post 1 image it looks like, rest should be in the comments)

If you where to call the FLBuilderPostGrid() you are able to locate the js assets connected to this module when editing, and you can then see the output of the frontend.js.php:
(see comment with #2 for screenshot)

As a reference, this is the frontend.js.php code for the post grid module, and you can see the same code here without the “real” data:
(see comment with #3 for screenshot)

Now, the appearance of the “issue”. If you now go and save the post and try to do the same, by calling the function to see where its located in the code, and then search for the node ID, you can still see the js from this module without the module being rendered (querySelector is returning null)
(see comment with #4 for screenshot)

I would understand that its my fault ofc that the javascript error as I mentioned, as I should have created its own scope for it etc. But if you have alot of different modules that sometimes are used just laying in the builder with a display of “never”, there could be alot of unused javascript and not to mention css!

I couldn’t find anything related to this with a quick search, so I thought to give it a post here :slight_smile:




Interesting issue, I have opened an internal ticket. I agree assets should be ignored if a module is set to display never ( unless the BB UI is active in which case they should be loaded )

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.