Skip to content

Instantly share code, notes, and snippets.

@richgcook
Created February 24, 2014 09:01
Show Gist options
  • Save richgcook/9184179 to your computer and use it in GitHub Desktop.
Save richgcook/9184179 to your computer and use it in GitHub Desktop.
Setting site root/URL for both local and remote development
var siteURL = 'http://www.website.com/';
if ( document.domain == 'localhost' ) siteURL = "http://localhost/website/";
// Example
$('.element').css('background-image', 'url("' + siteURL + 'assets/img/background.png")');
$('.element').next().find('img').attr('src', siteURL + 'assets/img/image.png');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment