I may have named this poorly; it is really more like a “URL construction” callback for resources. It can be called many different times, such as preloading, setting a background-image or video source, AJAX call for WebAudio, etc. Given the variety of ways/times this might be called, I’m not sure how useful the triggering element is. Do you have some example use cases?
myCallback() function @h_classen wrote above, note a few things:
event.url is what will be loaded.
- you can return a string and this will override the URL.
- it may be called multiple times for the same resource so generally make sure it returns the same URL if you are overriding