I created a website for big (Desktop) and small (Mobile) devices. Not only the .css files differ each other but also the .js files in which the animations are saved. My Problem now is, I don't know how to make the browser use the .js file for small devices if the display is small and on the other site the .js file for big devices if the display is big. Is there any possible solution to use only one webspace with two Java Script files automatically choosen by screen size?
5 Answers
Testing the user agent is more robust than testing the window width. Here's a library than can help you: WURFL.io
Just grab the lib to your page and add:
if (WURFL.is_mobile) {
//add mobiles scripts
}