I have an Office.js Task Pane add-in that doesn't do anything with the Office API until the user performs a specific action on the task pane UI. The UI is an angular.js SPA. So, naturally, there's nothing I need to do on Office.initilize. But, I kept running in to the below error until I gave Office.initilize an empty function.
SCRIPT5022: Unhandled exception at line 11, column 10360 in https://localhost:44300/Scripts/Office/1/office.js 0x800a139e - JavaScript runtime error: Office.js has not been fully loaded yet. Please try again later or make sure to add your initialization code on the Office.initialize function. office.js (11,10360)
The code that got rid of this was:
<script type="text/javascript">
Office.initialize = function (reason) {
// Nothing to do here..
}
</script>
Is this expected behavior? BTW, the error wasn't immediate or in response to any API calls or user interaction. It seemed it was being thrown off of a setTimeout inside Office.js file.
Office.initialize event occurs when the run time environment is loaded and the add-in is ready to start interacting with the application and hosted document and it must be initialized as a function at the beginning of the code file so that the Office.context property or any another property of office will be available when called from the functions.
Reference Links: https://msdn.microsoft.com/en-us/library/office/fp161139.aspx https://msdn.microsoft.com/en-us/library/office/fp142255.aspx
So in your scenario, it may be possible that you are not doing anything with this event but any another code in your app is using any property from office.js.
Hope this will help you.