Merge "mw.inspect: Include templates and messages in size"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 3 Mar 2017 19:12:35 +0000 (19:12 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 3 Mar 2017 19:12:35 +0000 (19:12 +0000)
resources/src/mediawiki/mediawiki.inspect.js

index fdaa989..6b3971e 100644 (file)
                                payload += $.byteLength( module.script.toString() );
                        }
 
+                       // Tally templates and messages. Calculate their JSON size so that keys
+                       // are included in the module size - in the case of messages, keys can be
+                       // longer than values - and so that empty objects are also included.
+                       $.each( [ module.templates, module.messages ], function ( i, object ) {
+                               if ( object ) {
+                                       payload += $.byteLength( JSON.stringify( object ) );
+                               }
+                       } );
+
                        return payload;
                },