Using two pieces of code one one page

Hi, I need to add two pieces of code on my homepage. One is to ensure the lightbox appears on every page visit, not just the first. The next is to show an element that should only appear on mobile. Any advice?

So far I’ve tried a couple of things, but nothing worked. The latest I tried being:
import wixWindow from ‘wix-window’;
$w.onReady(() => {
wixWindow.openLightbox(“Navigationhomepage”);
})
$w.onReady( function () {
if (wixWindow.formFactor === “Mobile”){
$w(“image6”).show();
}
});

There is a red dot next to the line $w(“image6”).show();

First code works but second one doesn’t

Hopefully somebody here can help?

Assuming that you have read up about the mobile only tutorials so that you know how to sit it all up and only works in live site and not on preview?
https://support.wix.com/en/article/corvid-writing-code-that-only-runs-on-mobile-devices
https://support.wix.com/en/article/corvid-tutorial-displaying-elements-in-mobile-only#:~:targetText=The%20basic%20steps%20to%20set,to%20display%20the%20hidden%20element.

Also, if this is to apply to your whole site, then you need to put it in your site tab and not your page tab, otherwise it will only work for that particular page that the code is on.

As it is just the one chunk of code, you only need the one onReady function in your code too.

Finally, for your red dot error on the image6 line of code, have you got an element on your desktop editor that has the id name of image6 and is set up to be hidden on load?

Thanks for your reply. I used code from a Wix post on how to show items on mobile only. Not sure how old that post was though, as since then I realised I don’t need code at all. I just have the image6 as hidden on desktop and then go to mobile and unclick the hidden button which means it’s now doing exactly what I wanted. No idea why Wix advised on using code. Maybe at the point of posting it as only possible that way.

I’d still be interested to know how to use two separate pieces of code though. Never know, might need it in the future.