making script a bit more robust

checking to see if localStorage exists and making this script able to be minfied.