π Widget Embed Browser Compatibility
Describe the bug Widget embed seems to only intermittently work. The issue seems to fire less frequently in Safari, but seems to be consistent with Chrome and Firefox - possibly a race condition.
An error is presented in the console:
hook.js:608 HiEvent widget error: Invalid script URL
To Reproduce Steps to reproduce the behavior:
- embed the script in the tags: (note that the hi.events domain is different to the domain where the widget is embedded)
- Embed a widget into the page
- Loading the page intermittently throws the error. I had some luck re-producing more often the embed website being in http://.
Additional context
widget.js uses document.currentScript in order to retrieve the current hostname. I believe this is not always reliable in every browser or scenario. PR incoming.
Thanks for the report, @creativeindustriesgroup! I haven't been able to recreate this, but after read some more about document.currentScript, I can see it could be a problem.
Hey Dave,
The widget is being used in a ~10 year old Wordpress website, so it is probably something to do with that.
The above PR does resolve the issue but I realise that it is not backwards compatible. I can revisit if necessary.
That said, Iβm developing a new website with Hi.Events API integrations so once thatβs done we will no longer be using the widget/have the problem.