Some minor fixes and optimizations
authorAlexander Ebert <ebert@woltlab.com>
Fri, 26 Jun 2015 15:56:10 +0000 (17:56 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 26 Jun 2015 15:56:10 +0000 (17:56 +0200)
com.woltlab.wcf/templates/headIncludeJavaScript.tpl
wcfsetup/install/files/acp/templates/header.tpl
wcfsetup/install/files/lib/system/template/plugin/JsFunctionTemplatePlugin.class.php

index c600cd8de39295769e0dca843e25f5104497e579..1d7e9be56065fd307ef0590b95c76f0fde783b4c 100644 (file)
@@ -194,7 +194,7 @@ requirejs.config({
                {/if}
                
                {* invoke background queue roughly every 10th request *}
-               if (Math.random().toString()[2] === '0') {
+               if (Math.random() < 0.1) {
                        require(['Ajax'], function(Ajax) {
                                // fire and forget background queue perform task
                                Ajax.apiOnce({
index cf908d1528895548cb1943e638ebd5111d449240..679a5d61be8ecc3d6c88a22c63abfbeddd2d5471 100644 (file)
                });
        </script>
        {js application='wcf' lib='jquery'}
+       
+       <script>
+               // prevent jQuery and other libraries from utilizing define()
+               __require_define_amd = define.amd;
+               define.amd = undefined;
+       </script>
        {js application='wcf' lib='jquery-ui'}
        {js application='wcf' lib='jquery-ui' file='touchPunch' bundle='WCF.Combined'}
        {js application='wcf' lib='jquery-ui' file='nestedSortable' bundle='WCF.Combined'}
        {js application='wcf' file='WCF' bundle='WCF.Combined'}
        {js application='wcf' acp='true' file='WCF.ACP'}
        <script>
+               define.amd = __require_define_amd;
                $.holdReady(true);
                WCF.User.init({$__wcf->user->userID}, '{@$__wcf->user->username|encodeJS}');
        </script>
index 6091ac5cb25c224fd5bef0b0b43bee0fc74562fc..3c1cd1a3805c2a681fb76e1a3d94accebfa8118a 100644 (file)
@@ -73,11 +73,11 @@ class JsFunctionTemplatePlugin implements IFunctionTemplatePlugin {
                        $src .= $tagArgs['file'];
                }
                
-               if (in_array($src, $this->includedFiles)) {
+               if (isset($this->includedFiles[$src])) {
                        return '';
                }
                
-               $this->includedFiles[] = $src;
+               $this->includedFiles[$src] = true;
                $src .= (!ENABLE_DEBUG_MODE ? '.min' : '') . '.js?v=' . LAST_UPDATE_TIME;
                
                $relocate = !RequestHandler::getInstance()->isACPRequest() && (!isset($tagArgs['core']) || $tagArgs['core'] !== 'true');