fix
diff --git a/emcc.py b/emcc.py
index 47a637f..3871bd2 100755
--- a/emcc.py
+++ b/emcc.py
@@ -3394,6 +3394,7 @@
       diagnostics.warning('legacy-settings', 'ignoring legacy flag --no-heap-copy (that is the only mode supported now)')
     elif check_flag('--use-preload-plugins'):
       options.use_preload_plugins = True
+      settings.CREATE_PRELOADED_FILES = True
     elif check_flag('--ignore-dynamic-linking'):
       options.ignore_dynamic_linking = True
     elif arg == '-v':
diff --git a/emscripten.py b/emscripten.py
index 550d003..f978775 100644
--- a/emscripten.py
+++ b/emscripten.py
@@ -168,6 +168,10 @@
     # exported.  In theory it should always be present since its defined in compiler-rt.
     assert 'emscripten_stack_get_end' in metadata.exports
 
+  if 'emscripten_run_preload_plugins' in settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE or \
+     'emscripten_run_preload_plugins_data' in settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE:
+    settings.CREATE_PRELOADED_FILES = True
+
   for deps in metadata.jsDeps:
     settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE.extend(deps.split(','))
 
diff --git a/src/compiler.js b/src/compiler.js
index 3591952..d1a5a58 100755
--- a/src/compiler.js
+++ b/src/compiler.js
@@ -68,13 +68,6 @@
   INCLUDE_FULL_LIBRARY = 1;
 }
 
-// emcc will add $Browser if --use-preload-plugins is passed. The other way in
-// which we can need the ability to create preloade files is if the user calls
-// the preloading logic directly.
-CREATE_PRELOADED_FILES =
-    DEFAULT_LIBRARY_FUNCS_TO_INCLUDE.indexOf('$Browser') >= 0 ||
-    DEFAULT_LIBRARY_FUNCS_TO_INCLUDE.indexOf('emscripten_run_preload_plugins') >= 0;
-
 // Side modules are pure wasm and have no JS
 assert(!SIDE_MODULE, 'JS compiler should not run on side modules');