diff --git a/Makefile b/Makefile
index f6c2ab4a877cf1271e55e02551ad8e4eabf6ba0c..dcd5cc17fde102d25c7d8f69ff0662b0f1f92f16 100644
--- a/Makefile
+++ b/Makefile
@@ -21,6 +21,7 @@ JS_TARGET := javascript/olm.js
 
 JS_EXPORTED_FUNCTIONS := javascript/exported_functions.json
 JS_EXTRA_EXPORTED_RUNTIME_METHODS := ALLOC_STACK
+JS_EXTERNS := javascript/externs.js
 
 PUBLIC_HEADERS := include/olm/olm.h include/olm/outbound_group_session.h include/olm/inbound_group_session.h include/olm/pk.h
 
@@ -147,7 +148,7 @@ js: $(JS_TARGET)
 .PHONY: js
 
 $(JS_TARGET): $(JS_OBJECTS) $(JS_PRE) $(JS_POST) $(JS_EXPORTED_FUNCTIONS)
-	$(EMCC_LINK) \
+	EMCC_CLOSURE_ARGS="--externs $(JS_EXTERNS)" $(EMCC_LINK) \
                $(foreach f,$(JS_PRE),--pre-js $(f)) \
                $(foreach f,$(JS_POST),--post-js $(f)) \
                -s "EXPORTED_FUNCTIONS=@$(JS_EXPORTED_FUNCTIONS)" \
diff --git a/javascript/externs.js b/javascript/externs.js
new file mode 100644
index 0000000000000000000000000000000000000000..8ec5b02dac1a56ee5a9e68a1c158285b48daf1a9
--- /dev/null
+++ b/javascript/externs.js
@@ -0,0 +1 @@
+var OLM_OPTIONS;
diff --git a/javascript/olm_pre.js b/javascript/olm_pre.js
index 5e8ed12954c43f07e96338e6c1b2c90cc9962cda..673b8685e60c3cc87d7f6bd0da1bbb975c57974a 100644
--- a/javascript/olm_pre.js
+++ b/javascript/olm_pre.js
@@ -21,10 +21,8 @@ if (typeof(window) !== 'undefined') {
 }
 
 /* applications should define OLM_OPTIONS in the environment to override
- * emscripten module settings (we still need to (re) declare the variable
- * otherwise the closure compiler becomes sad).
+ * emscripten module settings
  */
-var OLM_OPTIONS;
 if (typeof(OLM_OPTIONS) !== 'undefined') {
     for (var olm_option_key in OLM_OPTIONS) {
         if (OLM_OPTIONS.hasOwnProperty(olm_option_key)) {