I've looked into this once more, and it doesn't appear to make any difference if we wait for `pagesPromise` to be resolved (https://github.com/Snuffleupagus/pdf.js/blob/d43fdf23d0153786f46ef3f3da242a51f1d972c7/web/viewer.js#L1381) or use my horribly ugly first solution.
That would certainly be a lot cleaner, in my opinion! Would this be a better solution?