I'm working on a SPA where under some condition I have to log some browser and operating system data. So I loaded the script for the bowser library - when the condition is met - but unfortunately I can't use this in any way ... :(
On their official demo page - https://bowser-js.github.io/bowser-online/ - there is a global window.bowser object which can be directly used. But this simply doesn't happen when I just load the JS file on a web page.
Any idea what should I do? Or probably a better approach than mine?
I tried to load the library in several ways:
- With jQuery's getScript method:
$.getScript('https://cdn.jsdelivr.net/npm/bowser@latest/es5.js');
- With native JS:
var bowserScript = document.createElement('script');
bowserScript.src = 'https://cdn.jsdelivr.net/npm/bowser@latest/es5.js';
document.body.appendChild(bowserScript);
In both cases I see the network request in the browser and don't see errors in the browser's console.
I tried the same on different page on the website - and then all worked fine - I have the global window.bowser variable ... but not on my page ... :O
So - any idea what thing on this page could be the reason for the bowser library to not work there? ...