Index: lib/OpenLayers.js
===================================================================
--- lib/OpenLayers.js	(revision 10817)
+++ lib/OpenLayers.js	(working copy)
@@ -74,6 +74,7 @@
      * When we *are* part of a SFL build we do not dynamically include the 
      * OpenLayers library code as it will be appended at the end of this file.
       */
+// @exclude code:start
     if(!singleFile) {
         var jsfiles = new Array(
             "OpenLayers/Util.js",
@@ -340,6 +341,7 @@
             document.write(allScriptTags.join(""));
         }
     }
+// @exclude code:end
 })();
 
 /**
Index: tools/mergejs.py
===================================================================
--- tools/mergejs.py	(revision 10817)
+++ tools/mergejs.py	(working copy)
@@ -13,6 +13,14 @@
 #
 #    // @requires Geo/DataSource.js
 #
+# Code to exclude specified with a comment at the beginning and at the end:
+#
+# // @exclude code:start
+# ... code to exclude ...
+# // @exclude code:end
+#       This is useful primarily to remove in "OpenLayers.js" the code does 
+#       not run in single file mode.
+#
 # This script should be executed like so:
 #
 #     mergejs.py <output.js> <directory> [...]
@@ -225,18 +233,52 @@
     
     print
     ## Output the files in the determined order
+    EXCLUDE_CODE_START = "// @exclude code:start"
+    EXCLUDE_CODE_END = "\n// @exclude code:end"
+    EXCLUDE_CODE_ERROR = "\n    *** Misspecification: @exclude code ***\n   "
+    EXCLUDE_CODE_FINAL_ERROR = "*** Misspecification: @exclude code ***\n\
+        See \"Exporting:\" to determine affected files."
+    exclude_error = ""
     result = []
 
     for fp in order:
         f = files[fp]
-        print "Exporting: ", f.filepath
+        print "Exporting: ", f.filepath,
         result.append(HEADER % f.filepath)
         source = f.source
+        excluded_text = ""
+        while True:
+            start = source.find(EXCLUDE_CODE_START)
+            if start > 0:
+                if source[start - 1:start] == "\n":
+                    --start
+                else:
+                    start = -1
+            end = source.find(EXCLUDE_CODE_END)
+            if start == -1 and end == -1:
+                break
+            end = source.find("\n", end + 1)
+            if start > -1 and start < end:
+                size_excluded = end - (start + len(EXCLUDE_CODE_START) +
+                    len(EXCLUDE_CODE_END))
+                excluded_text += " + " + repr(size_excluded)
+                source = source[0:start] + "// excluded code: " + \
+                        repr(size_excluded) + " characters." + source[end:]
+            else:
+                print EXCLUDE_CODE_ERROR,
+                exclude_error = EXCLUDE_CODE_FINAL_ERROR
+                break
+        if excluded_text != "":
+            print "(excluded code:", excluded_text[3:], "characters.)"
+        else:
+            print ""
         result.append(source)
         if not source.endswith("\n"):
             result.append("\n")
 
     print "\nTotal files merged: %d " % len(files)
+    if exclude_error != "":
+        print exclude_error
 
     if outputFilename:
         print "\nGenerating: %s" % (outputFilename)

