Skip to content

Instantly share code, notes, and snippets.

@borsch
Last active June 25, 2016 06:59
Show Gist options
  • Save borsch/9651e95e5a6837e38d9f0994a62e78f7 to your computer and use it in GitHub Desktop.
Save borsch/9651e95e5a6837e38d9f0994a62e78f7 to your computer and use it in GitHub Desktop.
js separate file
// script.js
(function(exports){
// public function
// can be accessed outside of this file
exports.publicFunction = function(param1, param2){
};
// private function
// visible only inside this function(closure)
function privateFunction(){
}
})(window);
// page.jsp
..
<script src="/path/to/file/script.js"></script>
<script>
publicFunction(${someParamFromModel}, otherParam);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment