Help Center

Script Execution According to Device


Using PHP programming language, the easiest and most reliable way of recognizing a device is using the Mobile_Detect class, found at the following URL:

Mobile Detect recognizes the device (including tablets). Use the text chain User_agent combined with the HTTP header to detect the environment it is navigating in.

It has a test URL where we can see the result generated by the code. We can also observe the methods that can be implemented.

In the case of loading a script within the html page, and taking into account whether or not the device is a cell phone, we could use the following example:



Using Javascript programming language, there are several alternatives that vary in complexity.

1. - The simplest way is using the following function:


The function tests if window.orientation exists, since only mobile devices return true in this case.

Using JQuery, we could load the script as follows:



2. - Javascript also provides an alternative consisting of verifying whether the following attributes return true:


Once again, with the help of JQuery, we can add the corresponding script to the head


This website stores cookies on your computer. These cookies are used to collect information about how you interact with our website and allow us to remember you. We use this information in order to improve and customize your browsing experience and for analytics and metrics about our visitors both on this website and other media. To find out more about the cookies we use, see our Privacy Policy.

If you decline, your information won’t be tracked when you visit this website. A single cookie will be used in your browser to remember your preference not to be tracked.