Only use localStorage if supported.