Trigger app_initialized event *after* the 'global' IPython object is initialized

Also, include custom.js as a dependency of the main.js files.  This allows custom.js to have require statements that register event handlers before the events are triggered.