Added undefined checks for OS and language

This ensures that the OS and language are not undefined, which would
prevent the JS version of the site from being loaded due to an error