JS Code Validity in Desktop vs. Mobile Site

Probably a stupid question for all you Velo pros here but here it is anyway.

I have a lot of JS code written mainly for events in the desktop version of my site. The result is that when looking at the JS code of the mobile version it appears invalid in many areas. Usually because of unknown objects that are not displayed in the mobile version.

Is there a way to write the code better? Perhaps according to device type? Do you think it affects the site’s performance in any way?

Thanks

https://www.wix.com/velo/reference/wix-window/formfactor