How to hide unneeded element in mobile page without affecting the code

i have elements in desktop version that unneeded in mobile version, those elements are used in the code.
What is the best way to hide them without affecting and destroying the code?
The code cannot compile after hiding this elements from mobile version editor because it removes them from the DOM.

Thanks

Remove them from the mobile view, and limit the specific chuck of code to desktop only:

import wixWindow from 'wix-window';
$w.onReady(() => {
if(wixWindow.formFactor === "Desktop"){
//code for desktop
}
})