JavaScript device detector, viewport write and rewrite