The reason your code is working locally is because your local directory structure is different from your production directory structure.
That being said I believe that an absolute path to any external resources (javascript, images, and stylesheets) is best.