If you are looking for the code to only fire when someone is viewing the page from a phone, then this simple if command is what you need.
if
( window.innerWidth < 700 ) {
// what ever code you want to fire only on phone
}