IIFE pattern with parameter passed in. Can also pass in "window" to expose some of the functions to outside world. Or pass in jQuery and use it as "$" inside the function
<!DOCTYPE html>
<html>
<head>
<script>
var foo = "foo";
(function(bar){
var foo = "foo2";
console.log(foo); // "foo"
})(foo);
console.log(foo); // "foo"
</script>
</head>
<body>
<!-- page content -->
</body>
</html>