Ubidots Community

Including HTML content from github within HTML canvas

I’m creating a custom widget with HTML canvas.

Since I may want to have this widget in multiple dashboard, when I need to update or add a feature to the widget, I only want to do that from one place and have all the widgets update the next time the page loads.

I would love to be able to include the HTML, css and javascript from a file hosting site, like github. But I can’t seem to find a way to import/include HTML files.

What would be the best way to do this without violating the CORS policy?

Can we use the ajax “.load” to load HTML files? I get access errors.

Has anybody been able to use the 3rd party includes section on the HTML canvas to include a javascript file from github?

Hi @guitardenver,

I hope all is well,

Unfortunately, the HTML Canvas is not designed for such a case of including a JavaScript file from GitHub. It would be necessary to upload the code to a hosting and make a redirect in the widget. Meaning includes in the widget the URL location of the code (window.location = https://yoururl.com). Additionally, you can add 3rd library (e.g. jQuery), by inserting the URL containing the library, as described in the following article.

All the best,
-Isabel