You could do it on the client or the server. On the client, get hold of the script element and parse the src attribute.
<script id="myScript" src="script.js?myVar=foo"></script>
<script>
var s = document.getElementById('myScript');
s.src; // parse it and extract myVar
</script>
On the server, setup routes so that script.js goes to some handler written in a server-side language like PHP. In that case you could be outputting script.js dynamically. Here's an example in PHP.
script.js => script.php
<?php
header('Content-Type: application/javascript');
$myVar = $_GET['myVar'];
?>
// optionally expose myVar inside JavaScript
var myVar = <?php json_encode($myVar) ?>;
// regular JavaScript
alert(myVar);
var x = 10;