<!doctype html>
<html>
<head>
<!-- версии -->
<link rel="alternate" href="http://foo.com" id="desktop"
media="only screen and (touch-enabled: 0)">
<link rel="alternate" href="http://m.foo.com" id="phone"
media="only screen and (max-device-width: 640px)">
<link rel="alternate" href="http://tablet.foo.com" id="tablet"
media="only screen and (min-device-width: 641px)">
<!-- css media -->
<meta name="viewport" content="width=device-width">
<!-- загрузка самого js -->
<script src="device.js"></script>
</head><body>
<!-- для ручного переключения -->
<footer>
<ul>
<li><a href="?device=desktop">Desktop</a></li>
<li><a href="?device=tablet">Tablet</a></li>
<li><a href="?device=phone">Phone</a></li>
</ul>
</footer>
</body>
</html>
*{box-sizing:border-box;
margin:0;
padding:0;
border:0;
text-decoration:none;
}