diff --git a/lib/exe/js.php b/lib/exe/js.php
index ca9fc68a8681b2f1dc6a471feb42fd0a268975a2..4b78ade4b152479c529d1d4fdd7bc757bd29d048 100644
--- a/lib/exe/js.php
+++ b/lib/exe/js.php
@@ -165,13 +165,24 @@ function js_out(){
 
 /**
  * Load the given file, handle include calls and print it
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
  */
 function js_load($file){
     if(!@file_exists($file)) return;
+    static $loaded = array();
 
     $data = io_readFile($file);
-    while(preg_match('#/\*\s*!!include\s+([\w\./]+)\s*\*/#',$data,$match)){
-        $ifile = $match[1];
+    while(preg_match('#/\*\s*DOKUWIKI:include(_once)\s+([\w\./]+)\s*\*/#',$data,$match)){
+        $ifile = $match[2];
+
+        // is it a include_once?
+        if($match[1]){
+            $base = basename($ifile);
+            if($loaded[$base]) continue;
+            $loaded[$base] = true;
+        }
+
         if($ifile{0} != '/') $ifile = dirname($file).'/'.$ifile;
 
         if(@file_exists($ifile)){