Updated `global_functions.js`:

1. Fixed async callback issues.
2. Added functions to facilitate callbacks on resources loaded.