I am in the process of developing a JavaScript library that is compatible with both Windows Store (WinJS) applications and traditional HTML/JavaScript apps. The dependency I am utilizing loads dynamically and has separate SDKs for WinJS apps and standard websites, so detecting which environment my code is running in becomes crucial to load the appropriate one.
While I can use code like the snippet below to determine if it's a WinJS app, I'm interested in discovering a more elegant solution to identify the execution environment. Is there a cleaner method to ascertain this?
function isWinJS() {
return typeof Windows === 'object' &&
typeof Windows.UI === 'object' &&
typeof Windows.UI.Popups === 'object' &&
typeof Windows.UI.Popups.MessageDialog === 'function';
}