This might seem trivial, but the intval() is returning 0 in the following case:
$window_width2 = intval($window_width);
$window_width is holding a
window.innerWidth) which can not be converted to
0 is returned!
PHP is executed on
AJAX to emit that data over
Strings will most likely return 0 although this depends on the leftmost characters of the string. The common rules of integer casting apply.