Certain .JS files don't get rendered - DNN 5.x


Hi. There is an issue I keep runningy into that is driving me crazy :)
Several of our customers and now ,our site (recently upgraded to 5.x) have started having problems where some pages (for whatever reason very weird) don't render ceratin .JS files. For example dnn.controls.toolbars.js along with the dnnmenu.js and a few others. This only happens when you are in view mode or unauthenticated. We have a few modules that use the dnn toolbar and this ends up rendering an error, dnn.controls.toolbars is null. We always either disable to or set the visibility to false if the user isn't in edit mode, but it still renders code which throws the error. We can't identify any specific settings and have the problem with about 10% of our customers.
what causes this? What causes the JS file such as dnn.controls.toolbar.js to either render or not render to a DNN site?