What is the best way to run javascript after all content is loaded on the page?

jblumberg
Community Contributor

Some content in Canvas is not loaded until after the custom global javascript.  this means you need to wait in some cases until this content loads.

At Champlain College we are using an older flavor of  @kenneth_larsen  JavaScript for accomplishing this.  Unfortunately we are experiencing issues in a number of situations (content-pages works fine, but it is broken in Groups).

Here is a link to the code we currently use:

[JavaScript] Old code for loading javascript with Canvas (don't use) - Pastebin.com

It looks like some of the recent cases have broken this code, and our javascript is waiting to the fallback time of 3 seconds to load on some pages.

I know we need to replace this and are looking for advise on how best to approach this problem.  Developing separate clauses for each type of Canvas page seems tedious and I am unsure what is most likely to remain consistent across Instructure releases.