Is it possible for JQuery
to alter URLs within a CSS
or Javascript
resource before they are loaded into the browser, or even as they load in the browser?
URLs
typically point to resources such as images and fonts.
I have been considering this idea because I often work on large single-page web apps/websites where during development, the root path for resources is relative, but in production, the root path points to a different URL
.
Is there a solution to address this issue? I was thinking of having a JavaScript function that would check:
(pseudo-code)
var isDevMode = true;
if (isDevMode) {
root_path = "/";
} else {
root_path = "http://somewhere.com/"
}
This way, I can easily set it and ensure that all paths in my HTML file, including CSS on the page, obtain the correct root path.