In our webapp, we would like to be able to show different content at the same URL based on the host from which the site is opened. E.g https://localhost:44300 will behave differently depending on if it is opened from within a browser or an office js taskpane.
While that is the case, we would like not to include the office.js javascript until we know that the website is accessed from within an office js taskpane. Therefore it is also not possible to use Office.context.requirements.isSetSupported.
The way we do it at the moment is by looking at the URL since it includes the _host_Info. As an example we make the following check right now
if(window.location.search.indexOf('_host_Info=Word') > -1) { /* initiate app for word js addin */ }
Even though this works, it doesn't seem to be a good solution - especially if we want to navigate to other pages on the website. We therefore hope that there could be another way that the Office js host could be detected without having to include Office.js script beforehand