Wrap js code in closures