I try to use relative URLs where possible (so I don’t have to worry about whether or not the page is secure). I typically create a ColdBox setting in my config file for where I store that type of asset like so:
LayoutPath = “/layouts”,
Then I simply do this:
For assets served from my CDN (another domain), I have a utility function that handles the building of the URL with the correct domain and http/https replacement if neccessary.