|
Server : LiteSpeed System : Linux quebec.us.hostns.io 5.14.0-687.42.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Aug 27 11:55:12 EDT 2026 x86_64 User : gazetufm ( 1431) PHP Version : 8.1.35 Disable Function : NONE Directory : /home2/gazetufm/pelasgus.al/wp-content/plugins/optimole-wp/assets/js/modules/ | |
|
Path: //home2/gazetufm/pelasgus.al/wp-content/plugins/optimole-wp/assets/js/modules/device.js
Size: 1.36 KB
Permissions: 0644
/**
* Optimole Device Detection Module
* Handles device type detection based on screen width
*/
import { optmlLogger } from './logger.js';
/**
* Device detection utilities
*/
export const optmlDevice = {
/**
* Device type constants
*/
DEVICE_TYPES: {
MOBILE: 1,
DESKTOP: 2
},
/**
* Screen width threshold for mobile/desktop detection
* This is similar to what PageSpeed Insights uses
*/
MOBILE_BREAKPOINT: 600,
/**
* Determine device type based on screen width
* @returns {number} Device type (1=mobile, 2=desktop)
*/
getDeviceType: function() {
const width = window.innerWidth;
if (width <= this.MOBILE_BREAKPOINT) {
optmlLogger.info('Device detected as mobile based on width:', width);
return this.DEVICE_TYPES.MOBILE;
}
optmlLogger.info('Device detected as desktop based on width:', width);
return this.DEVICE_TYPES.DESKTOP;
},
/**
* Check if current device is mobile
* @returns {boolean} True if mobile device
*/
isMobile: function() {
return this.getDeviceType() === this.DEVICE_TYPES.MOBILE;
},
/**
* Check if current device is desktop
* @returns {boolean} True if desktop device
*/
isDesktop: function() {
return this.getDeviceType() === this.DEVICE_TYPES.DESKTOP;
}
};