Is it possible for the mobile version of my site to be loaded based on browser. Chrome doesn't respond well to certain effects I have on my site, and was wondering if I could get my simplified, mobile version to load. Thanks in advance.
Asked
Active
Viewed 42 times
0
-
What's the difference (from the browser's perspective) between the mobile version and the normal one? Are the two different sites (i.e. `m.mywebsite.com` vs. `www.mywebsite.com`), or is it just different css/scripts? – Anonymous Apr 23 '18 at 21:23
-
It's just a different script. – skyper12345 Apr 23 '18 at 21:31
-
How does the browser decide which script to use? – Anonymous Apr 23 '18 at 21:33
-
Possible duplicate of https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser – MMallette Apr 23 '18 at 21:35
-
1The screen size determines whether to use mobile or full version – skyper12345 Apr 23 '18 at 21:45
-
Please post some code! Where is the app deciding which assets to load? – theUtherSide Apr 23 '18 at 22:59
1 Answers
1
You can use Window.matchMedia(media query):
if (window.matchMedia("(max-width: 500px)").matches) {
/* The viewport is less than, or equal to, 500 pixels wide */
} else {
/* The viewport is greater than 500 pixels wide */
}
https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia

Marina ES
- 250
- 2
- 6