if you make this a defined module, and it requires legacyapp.js this will not run until that module is loaded; thus you can bind to the tab load event instead