Relative URLs in Javascript - A Solution
I've previously written about absolute and relative paths in web development, and this follow-up post is here to show the method I've been using to get around the problem.
The secret sauce is the old HTML <base> tag. Simply
output this in the <head> section of your template,
with the href attribute set to the full URL of your site's
root, then you can use a simple helper function like the one below to
build full URLs in your javascript!