I've written some javascript that does a bunch of asynchronous API calls to display third-party content on the current page.
(I also do this as a way of displaying confluence content instead of using the content macros, because too many content macros on one pages slows the page load enough for users to start complaining; asynchronous loads provide a better user experience.)
This works fine, except that if I click the 'Edit' button, I have to wait while all the javascript re-runs (i.e. creates the view mode again*) before the page even tries to switch to edit mode.
*I presume this always happens when switching any page into edit mode, but we don't normally notice it?
Is there any way to stop the javascript running on this pre-edit page view load? Something wrapped around my code that says "if edit button has been clicked, abort"?
(I don't have access to create plug-ins etc btw - only front-end javascript)
PS - we have collaborative editing enabled