I currently have a JavaScript file that gets loaded in my SharePoint pages.
jQuery(document).ready(function() {
ExecuteOrDelayUntilScriptLoaded(myfunction(), "sp.js");
});
myfunction = function(){
/*Do something here.*/
};
Now the JavaScript runs just fine, however on a list page, it prevents the ribbon from loading the List tab. In the console I get below error.
SCRIPT5007: Object expected init.debug.js, line 5153 character 5 error.
Even if I comment out all of the function so it looks exactly like above I still get the error message.
I have noticed that if I change "sp.js" to "sp.debug.js" I do not get the error message. From looking at the scripts that are loaded on the page, this makes sense as sp.debug.js is loaded and not sp.js. I don't really want to put sp.debug.js in the javascript code as when it reaches production servers, they won't be using sp.debug.js. I've never notice this happen before with any code that has ExecuteOrDelayUntilScriptLoaded(jsfunction(), "sp.js"). Is there a way to get it to work for both environments like with a #ifdebug statement in javascript? Or some other idea.