The investigation and problem I experienced where in CRM 2011 but I think it would be the same in CRM 2013, I had a problem with the ribbon javascript but I didn’t have a clue where it was because I had never seen a syntax error in the Javascript ribbon.
I put a debugger statement in the ribbon, so it would drop into the debugger. The reason you put the debugger statement into the Javascript code is because when the ribbon is loaded it is loaded in dynamic Javascript script block, this means when you press F5 it creates a brand new script file and you won’t have time to put a breakpoint in it if you bring up the debugger by pressing F12.
So I put my debugger line in and then the code hit my various display/enable javascript methods and I could step through them but the syntax error kept appearing.
I still wasn’t sure where/what the problem was.
I pressed F12 to bring up the debugger and this was bring up a syntax error

I turned on fiddler and found on one of the calls I was getting a nasty red triangle on one of the calls.
The thing which kept bugging me was it was a syntax error
I could see the code and it looked fine (although syntax errors are not obvious to the naked eye). The file compiled in Visual studio and pressing F12 to get the debugger didn’t throw an error, so this would suggest the javascript syntax was not the problem
frustrating
I fired up the Visual Ribbon Editor for CRM 2011/2013
In the Visual Ribbon Editor here you have display rules, enable rules and action.
There was no disable rule
there was an enable rule and an action rule which both called a javascript function, you can see below

Slowly something clicked, the error was trying to call the action, why was it calling the action whilst loading the form. Logically the ribbon has to make sure the Javascript method exists so when the user presses the button something will happen but why was it triggering a syntax error whislt loading the ribbon?
Syntax error, ribbon load…..hmmmmm
Look at the two rules, although I’m not showing you the actual file, look at the position of the library and the function boxes!
Finally after hours and dragging more eyes to the problem, my colleague found the problem by exporting the Ribbon xml, hazaaar the problem was obvious
The library and function values from the enable rule had been copied into the action rule, only this didn’t work because the function and library boxes are in different places.
He found the library – which should be the javascript library was pointing to a function.
Ribbon object not found
A new day a new ribbon problem. Today on one of the forms the ribbon wasn’t loading and I was getting an error
SCRIPT5007: Unable to get value of the property Ribbon ‘value’ of undefined or null reference
The first thing I checked was to see if the function and library values were correct, they were.
In the Javascript files we use we build up the names spaces so the function calls are like this
Hosk.Functions.Account.Ribbon.NewAccount()
To find the problem I had to put debugger statements in the enable/action javascript rules and walk through them.
Eventually I found one where Javascript file hadn’t been loaded, so when it it was trying to call a function the javascript file was loaded, the function didn’t exist and we got a null reference.