Skip already included JavaScript files
authorAlexander Ebert <ebert@woltlab.com>
Fri, 26 Jun 2015 12:58:52 +0000 (14:58 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 26 Jun 2015 12:58:52 +0000 (14:58 +0200)
wcfsetup/install/files/lib/system/template/plugin/JsFunctionTemplatePlugin.class.php

index c71989c2d82f1cb1c2f3379184b3e9d5aa812351..a318370a21d8eb5772e55b55593fd62a88b42db5 100644 (file)
@@ -33,6 +33,12 @@ use wcf\util\StringUtil;
  * @category   Community Framework
  */
 class JsFunctionTemplatePlugin implements IFunctionTemplatePlugin {
+       /**
+        * list of already included JavaScript files
+        * @var array<string>
+        */
+       protected $includedFiles = [];
+       
        /**
         * @see \wcf\system\template\IFunctionTemplatePlugin::execute()
         */
@@ -66,6 +72,11 @@ class JsFunctionTemplatePlugin implements IFunctionTemplatePlugin {
                        $src .= $tagArgs['file'];
                }
                
+               if (in_array($src, $this->includedFiles)) {
+                       return '';
+               }
+               
+               $this->includedFiles[] = $src;
                $src .= (!ENABLE_DEBUG_MODE ? '.min' : '') . '.js?v=' . LAST_UPDATE_TIME;
                
                $html = '<script' . (!isset($tagArgs['core']) || $tagArgs['core'] !== 'true' ? ' data-relocate="true"' : '') . ' src="' . $src . '"></script>'."\n";