In CSS, any image path is relative to the CSS file location.
f.ex if I put the CSS file in /media/css/mystyles.css and use something like
/media/css/mystyles.css
You can flip through <head>'s childNodes, find your <script> tag, get the url of said script, and compute the url of your image.
<head>
<script>