Detect mobile or desktop mode from Javascript
I have two sightly templates- mobile.html and desktop.html and these 2 templates are called from a common file.
I want to call the desktop.html only for desktop mode and the mobile.html for mobile mode.
I am trying to call a js file using js Use API from this common file which should return a boolean value based on some calculations using window.innerWidth so I can use data-sly-test and call the templates based on it.
But the if condition for window.innnerWidth is not working.
Is it because of the use API the window.innerWidth is failing?
If not, what else could it be ? Anybody who has tried implementing similar use case
Note : I am trying to avoid Java and would want to use javascript.