Display message if in landscape view for mobile

Hello,
since Wix pages are not (yet) convienent to view in landscape mode for mobile view (but in portrait view only), I want to display a lightbox to give a message “please switch to portait view”.
For this I have created a code that is basically doing the following:

i) checks if page is in mobile
ii) if yes, then:
checks if windowWidth > windowHeight as “indicator” if landscape or portrait (thanks to the wixWindow.formFactor)
iii) if yes, then open a Lightbox

You can see the code here below.
Basically, it works, but I have the following questions:

  1. does it make sense to “embedd” this code into the $w.onReady( function () ?
    In other words, I don’t know if it is better to apply this function once the page is loaded
    What is the difference?

  2. Overall, I have the feeling it is a bit slow until lightbox appears.
    Moreover - I think - this code is being run once - but what to do if the user changes position once the page is loaded. Any tricks to apply this routine once user changes from portrait to landscape at any time
    Any ideas for performance speed-up

Any comments are welcome (as I am quite new to coding as such)!
Thanks a lot,
Adrian

import wixWindow from ‘wix-window’;
// $w.onReady(function () {
//TODO: write your page related code here…
// …
if (wixWindow.formFactor === “Mobile”){
wixWindow.getBoundingRect()
.then( (windowSizeInfo) => {
let windowHeight = windowSizeInfo.window.height;
let windowWidth = windowSizeInfo.window.width;
if (windowWidth > windowHeight){
wixWindow.openLightbox(“Lightbox_Message”)
}
})
}