diff --git a/Makefile b/Makefile
index f63274c3b6a8681d233fa96ba90dc2fe7bb22bac..d45ade7ac320a58eaadcec6f621370296c9e471b 100644
--- a/Makefile
+++ b/Makefile
@@ -69,7 +69,7 @@ merge_xsl:
 
 merge_js:
 	for f in ${BUILDFILELIST} ; do source "$$f" ; done ; \
-	BUILD_JS_DIST_BUNDLE=$${BUILD_JS_DIST_BUNDLE} misc/merge_js.sh $${MODULE_DEPENDENCIES[*]}
+	JS_DIST_BUNDLE=$${JS_DIST_BUNDLE} AUTO_DISCOVER_MODULES=$$AUTO_DISCOVER_MODULES misc/merge_js.sh $${MODULE_DEPENDENCIES[*]}
 
 EXCLUDE_EXPR = %~ %.backup
 BUILDFILELIST = $(filter-out $(EXCLUDE_EXPR),$(wildcard build.properties.d/*))
diff --git a/build.properties.d/00_default.properties b/build.properties.d/00_default.properties
index 36d296789f6058d106b450f405af726bf0273b9d..40d2610c10c3d6ebe99e23ef5db813fa7b919c22 100644
--- a/build.properties.d/00_default.properties
+++ b/build.properties.d/00_default.properties
@@ -91,6 +91,18 @@ BUILD_CUSTOM_IMPRINT='<p> Put an imprint note here </p>'
 ##############################################################################
 BUILD_MODULE_EXT_TRIGGER_CRAWLER_FORM_TOOLBOX="Tools"
 
+##############################################################################
+# Build a dist file containing all JS code from the files in the
+# MODULE_DEPENDENCIES array.
+##############################################################################
+JS_DIST_BUNDLE=TRUE
+##############################################################################
+# TRUE means that all javascript sources which are no mentioned in the
+# MODULE_DEPENDENCIES array will be added in no particular order into the
+# build. If you need to guarantee a specific order (in which the are loaded or
+# appear in the dit file) you need to add them to the MODULE_DEPENDENCIES.
+##############################################################################
+AUTO_DISCOVER_MODULES=TRUE
 ##############################################################################
 # Module dependencies
 # Override or extend to specify the order of js files in the resulting
diff --git a/misc/merge_js.sh b/misc/merge_js.sh
index 2e674a511404660cddb5d88637e037f6db6da823..506a65866db42c329b4e19c197842f04bdfc4aca 100755
--- a/misc/merge_js.sh
+++ b/misc/merge_js.sh
@@ -41,7 +41,7 @@ ALL_SOURCES=()
 
 _create_jsheader () {
     _JS_INCLUDE=
-    if [ "$BUILD_JS_DIST_BUNDLE" == "TRUE" ] ; then
+    if [ "$JS_DIST_BUNDLE" == "TRUE" ] ; then
         _SIZE=$(( $(wc -c ${DIST_BUNDLE_TARGET} | awk '{print $1}')/1024))
         echo "including ${DIST_BUNDLE} (${_SIZE}kB) into ${JSHEADER_TARGET}"
         _JS_INCLUDE="
@@ -85,7 +85,7 @@ _create_jsheader () {
 }
 
 function _merge () {
-    if [ "$BUILD_JS_DIST_BUNDLE" != "TRUE" ] ; then
+    if [ "$JS_DIST_BUNDLE" != "TRUE" ] ; then
         return 0
     fi
     _SOURCE=$2
@@ -110,11 +110,13 @@ for _SOURCE in ${CORE_MODULES[@]} ; do
     _merge "core" "${PUBLIC_JS_DIR}${_SOURCE}" $DIST_BUNDLE_TARGET
 done
 
-# load other js files but exclude any subdirectory
-for _SOURCE in $(find ${PUBLIC_JS_DIR}* -prune -iname "*.js") ; do
-    [[ ! " ${ALL_SOURCES[@]} " =~ " ${_SOURCE} " ]] && ALL_SOURCES+=(${_SOURCE})
-    _merge "extension" ${_SOURCE} $DIST_BUNDLE_TARGET
-done
+if [ "$AUTO_DISCOVER_MODULES" == "TRUE" ] ; then
+    # load other js files but exclude any subdirectory
+    for _SOURCE in $(find ${PUBLIC_JS_DIR}* -prune -iname "*.js") ; do
+        [[ ! " ${ALL_SOURCES[@]} " =~ " ${_SOURCE} " ]] && ALL_SOURCES+=(${_SOURCE})
+        _merge "extension" ${_SOURCE} $DIST_BUNDLE_TARGET
+    done
+fi
 
 # for `make test`
 for _SOURCE in $(find ${PUBLIC_JS_DIR} -ipath "${PUBLIC_JS_DIR}modules/*.js") ; do