Just a friendly note because this is the second time (at least) that I've run into this problem and it is very frustrating and unintuitive to resolve.

 

We are on a hosted instance (7.0.3) and have several custom macros built. These load some javascript to do their thing (display a video player, dynamic tables, etc.). I was just refactoring our code and extracted some javascript out from being generated in the Macro Java class to loading from a js file because it was soooo much easier to debug and tweak etc.

 

Well, then we noticed that our Overview Pages would fail to load the Layout/Widget Panel when editing and instead would just get stuck on the 'Loading' spinner graphic.

 

I narrowed it down to only when a document which contained the macro I just modified was being loaded in a View Document widget. Not just that, but only when MULTIPLE of these macros were in that document.

 

Very curious I thought.

 

So after flailing around for a while, having a good yell at the computer, it finally dawned on me that I had seen this happen before with another macro that I also "simplified" a year or so ago.

 

What I recalled then, was that it was a problem with how the widgets are loaded "safely" when in Overview Page edit mode. What this does is extract all the scripts  and then load them dynamically or something weird. The problem is that if it hits the same script src url twice, it chokes and fails silently. What a nice "safe" feature.

 

Problem is that the Widget Panel is waiting on that safelyLoad call to return before removing the loading placeholder.

 

Now for the solution. Instead of loading this js file with the macro itself, I added a reference to it in header.soy. Lame, that means it will be loaded on every page, but it fixes the problem. Downside is that it loads a few more KB on each page that doesn't need that javascript, but because of what is in the js file, there is no detrimental effect to functionality.

 

Anyway, hope this helps you not struggle for a couple hours like I did (multiple times). And hopefully, it will help me not do the same next time.

 

Cheers,

Scott