Using Media Queries to Only Include Js Files on Mobile

Using Media Queries To Only Include JS Files On Mobile

How about using javascript for that?

<script type="text/javascript">

if (screen.width < 980) {

document.write('<script type="text/javascript" src="mobile.js"></script>');
}

</script>

Using Media Queries To Only Include JS Files On Desktop

Try window.innerWidth,

if (window.innerWidth > 980) { 
document.write('<script type="text/javascript"> ....... </script>');
}

Media Queries to load resource?

If you make this, your site will not be responsive. Responsive said that design adapts to resolutions, not only devices, and when a desktop screen has a 600 px width you must to show tablet version, no? The best way to reduce the files is minifying all your css in one file in production version, and in dev version you have got all splitted css



Related Topics



Leave a reply



Submit