Running Javascript on Dashbaord

Hi I have designed a few basic dashboards in the past. This time around I am trying to use html for the first time and it has been mostly successful. However I am running into issue while trying to use Javascript code in the dashboard. I am planning to bring in widgets from OpenWeatherMap and while I can see the widget working in the edit mode, I cannot save the dashboard with this widget. I get the following error while saving:

Message: Uncaught Error: Could not save Dashboard. Error: Invalid dashboard content, content not saved
Route: dashboard/edit?id=6xxxx
Line: 1191
Column: 9

I have tried bringing in the Portlet from Pvoutput before and was running into similar issues as the Portlet also uses Javascript.
Any help will be appreciated.