Maybe `var initialLocale = localStorage.getItem(l20nProvider.localeStorageKey) || documentL10n.supportedLocales[0];`? You should also wrap it in try/catch.