Custom File Location (css, js, images)

You can also change the image path using JavaScript and Hype Events on the fly. Have look how I am using it for the Cloud Image CDN but it can be tweaked to any other CDN.


Basically, this is the callback to put in your site (Head HTML)

function resourceLoad (hypeDocument, element, event) {
    // do your modifications of event.url and return the result
}

if("HYPE_eventListeners" in window === false) window.HYPE_eventListeners = Array();

window.HYPE_eventListeners.push({"type":"HypeResourceLoad", "callback": resourceLoad});

… and from there you can hook up your callback to edit the URL before Hype start loading it.


Here is the event described on Hype CookBook

2 Likes