Looks like the safest place is https://github.com/ckeditor/ckeditor-dev/blob/14e3bab99f1d4b968dd44e9b4e5b408e97b26758/core/plugins.js#L37 because it makes sure that the function won't be attached multiple times.