MAMA: Scripting - quantities and sizes

By Brian Wilson

Index:

  1. Introduction
  2. Quantities of script components in Web pages
  3. Venn diagram: script usage by type
  4. Sizes: external script
  5. Sizes: embedded script
  6. Sizes: event handler script
  7. Sizes: hyperlink JavaScript

Introduction

Scripting was detected in 2,617,305 of MAMA's URLs, from 4 different sources:

All of these sources together form an interesting and complex backdrop on which to paint our analysis of what MAMA discovered about script usage on the Web.

Quantities of script components in Web pages

Of the 4 possible methods to specify scripting, the most popular technique found by MAMA is embedded script - just over 88% of scripts used this method. External scripts and event handler attributes were used in a similar number of cases, both used in ~2/3 of all scripting cases. The "quantity per page" values and other counters represent the number of occurrences for the specific syntax that was discovered for a URL. For example, the maximum number of external scripts encountered in any single page was 264; the maximum number of event handlers discovered was 37,658. The average "per-page" numbers listed in the table below (Fig 2-1) apply where that type of scripting was used and does not cover the total MAMA URL space.

Fig 2-1: Totals for different methods of script inclusion
Script typeDescriptionTotal URLs
containing
script type
% Total
script
usage
Most
popular
quantity
Max.
quantity
per page
Avg.
quantity
per page
Embedded scriptsInline content of the SCRIPT element2,303,363 88.01%12,0103.6
Event handlersContent of attributes beginning with "on"1,707,594 65.24%137,65819.2
External scriptsContent from SCRIPT/Src URLs1,651,383 63.09%12642.5
JavaScript URLsHyperlink URLs prefaced by "javascript:"483,936 18.49%13,3964.9

Maximum quantities of the script usage types

Fig 2-2: URLs with the most embedded scripts
URLEmbedded
script qty
http://www.realestateinform.com/2,010
http://www.momentoffame.com/photopost/index.php1,901
http://www.cafes.es/1,865
Fig 2-3: URLs with the most event handler scripts
URLEvent
script qty
http://www.gibson.com/en-us/Divisions/Gibson%20Original/Gibson%20Mandolins/37,658
http://ww2.keeneland.com/default.aspx (URL no longer active)11,583
http://www.mriresearch.org/7,630
Fig 2-4: URLs with the most external scripts
URLExternal
script qty
http://www.basisonline.org/the_wager/index.html264
http://www.hear.org/starr/hiplants/images/family/rubiaceae.htm255
http://www.schwarzeneggergovernor.com/164
Fig 2-5: URLs with the most JavaScript URL scripts
URLJavaScript
URL qty
http://consc.net/mindpapers/2/all/3,396
http://www.anrc.ro/DesktopDefault.aspx?tabid=1318 (URL no longer active)2,495
http://www.affairsoftheheart.info/2,382

Venn diagram: script usage by type

The most common script usage was the intersection of external and embedded script with event handler attributes. The rarest combination detected was the use of only event handler script with JavaScript URLs. To get a clearer view of the uses and intersections of the different script specification methods, let's examine a helpful Venn diagram. Of all the Venn diagrams for MAMA, this one is the most daunting; a 4-part intersection is rather complex.

Note: Region sizes are not to scale

Venn diagram for script usage types

Sizes: external script

Unlike the 3 other scripting component types, the distribution of sizes for external scripts is not uniform. It does not spike immediately at small sizes and then quickly level off. There are at least two noticeable peaks in the middle of the range - first a modest one between 14-16,000 characters, and then a much bigger one between 20-22,000 characters. The average total external script size is thus increased to a significant 26,550.4 characters. The maximum size recorded by MAMA was an incredible 10,008,659 characters, but this result was not directly reproducible several months later at the time of writing. Instead, another URL took up the torch - lasallecounty.org with a maximum external script size of 14,257,992 characters in only 2 external scripts. This has to be an authoring mistake. One would not expect such an outlandish size case to remain this way, as users would likely never tolerate waiting for a script that big to finish loading. The other URLs that made MAMA's maximum external script size list were 1/4 the size of lasallecounty.org or less.

Size distribution of external script

Fig 4-1: External script sizes
Size rangeFrequency Size rangeFrequency Size rangeFrequency
=01,907,375>8000 && <=900029,061 >26000 && <=2800032,659
>0 && <= 50075,958>9000 && <=1000018,163 >28000 && <=3000036,898
>500 && <=100080,535>10000 && <=1200032,588 >30000 && <=3500067,502
>1000 && <=2000103,223>12000 && <=1400027,771 >35000 && <=4000065,848
>2000 && <=300099,197>14000 && <=1600085,204 >40000 && <=4500037,688
>3000 && <=400070,486>16000 && <=1800045,346 >45000 && <=5000028,266
>4000 && <=500043,395>18000 && <=2000029,499 >50000 && <=75000111,160
>5000 && <=600046,157>20000 && <=22000147,081 >75000 && <=10000046,699
>6000 && <=700048,650>22000 && <=2400054,757 >100000 && <=15000034,957
>7000 && <=800028,468>24000 && <=2600045,402 >15000029,187

Maximum sizes of external script

Fig 4-2: URLs with the largest external script sizes
URLExternal script
size (chars)
http://www.lasallecounty.org/index.htm14,257,992
http://www.dockendorf.biz/index.html3,486,769
http://www.nordicway.com/index.html2,735,461
http://www.languagesource.com/1,996,866

Sizes: embedded script

The overall size of embedded scripts tapers off gradually, with the average size being 2,481.8 characters. The largest embedded script total size that MAMA analyzed was 2,937,643 characters, but the case with the biggest live verifiable size was 2,251,905 characters (pathguy.com). The URLs representing the maximum values used scripting in some unusual ways. real-estate-denver-colorado.com is a particularly odd case, filled with over 73,000 lines of JavaScript devoted to form validation of 12,190 specific invalid user names for its site. Another case (asciimation.co.nz) stores frame after frame of ASCII pictures representing the Star Wars saga as JavaScript arrays (I have a bad feeling about this).

Size distribution of embedded script

Fig 5-1: Embedded script sizes
Size rangeFrequency Size rangeFrequency Size rangeFrequency
=01,208,935>7000 && <=800026,361 >25000 && <=300008,525
>0 && <= 500776,696>8000 && <=900020,826 >30000 && <=350004,505
>500 && <=1000340,766>9000 && <=1000016,121 >35000 && <=400003,001
>1000 && <=2000524,775>10000 && <=1200022,112 >40000 && <=450002,390
>2000 && <=3000213,289>12000 && <=1400014,856 >45000 && <=500001,243
>3000 && <=4000116,929>14000 && <=1600012,299 >50000 && <=750003,473
>4000 && <=500079,642>16000 && <=180008,181 >75000 && <=1000001,089
>5000 && <=600050,892>18000 && <=200005,484 >100000 && <=150000591
>6000 && <=700035,840>20000 && <=250009,832 >150000527

Maximum sizes of embedded script

Fig 5-2: URLs with the largest embedded script sizes
URLEmbedded script
size (chars)
http://www.pathguy.com/cg35.htm2,251,905
http://www.real-estate-denver-colorado.com/2,247,372
http://www.asciimation.co.nz/2,192,120
http://www.ymps.ttct.edu.tw/index.html1553,583

Sizes: event handler script

The total size of most event handler uses is less than 2,000 characters, with over half of the uses being less than 500 total characters. For a rough calculation, we can add this together with the average quantity of event handlers (19) mentioned previously, giving an approximate size per average event handler of 26 characters. True, combining these averages together in such a manner is questionable, but it helps to demonstrate that event handlers will likely be used for very short, atomic script code or to point to longer functions in external and embedded scripts.

The maximum recorded total size for event handlers was 3,437,290 characters, but live analysis of some of these chart-topping URLs revealed a maximum of only 1,812,178 characters - just over half as many (but still extremely large). The average total event handler size was 973.0 characters.

Unlike the typical brief uses already mentioned, some authors go overboard when using event handlers (using hundreds or even thousands of instances). One hopes that such code is produced programmatically, because it would be difficult to keep track of so many individual code snippets; not to mention that such uses waste a reader's bandwidth. The ohiosmiles.com, keen.land.com and reactome.org cases each apply several event handlers to EVERY link, resulting in thousands of instances in a single document...Exhausting!

Size distribution of event handler script

Fig 6-1: Event handler script sizes
Size rangeFrequency Size rangeFrequency Size rangeFrequency
=01,812,178>7000 && <=80004,609 >25000 && <=30000639
>0 && <= 500910,605>8000 && <=90003,196 >30000 && <=35000346
>500 && <=1000326,661>9000 && <=100002,474 >35000 && <=40000245
>1000 && <=2000263,615>10000 && <=120003,366 >40000 && <=45000160
>2000 && <=300094,675>12000 && <=140001,892 >45000 && <=50000152
>3000 && <=400040,751>14000 && <=160001,311 >50000 && <=75000295
>4000 && <=500020,200>16000 && <=18000852 >75000 && <=100000101
>5000 && <=600012,051>18000 && <=20000610 >100000 && <=15000078
>6000 && <=70007,033>20000 && <=250001,039 >15000046

Maximum sizes of event handler script

Fig 6-2: URLs with the largest event handler script sizes
URLEvent script
size (chars)
http://www.ohiosmiles.com/1809979
http://ww2.keeneland.com/default.aspx (URL no longer active)1598238
http://www.reactome.org/496996
http://www.conflictlab.com/chronicle/911/459875

Sizes: hyperlink JavaScript

The size distribution chart shows a rapid falloff in popularity after the 500 character mark, indicating that this type of scripting is usually used sparingly and only in small snippets. As recorded in MAMA, the maximum detected hyperlink JavaScript size was a very weighty 1,045,812 characters. The live analysis of that URL shows a significant reduction, but it is still the top value: 589,097 characters. The average number of characters used for hyperlink JavaScript, when this type of script is used, was 217.7 characters. Itsandil.rediffiland.com had its hyperlink JavaScript size distributed across a main page and 6 IFRAMEs. The star-academy.info case is a little different, in that it used all of its hyperlink JavaScript in the fallback content inside an IFRAME element.

Size distribution of hyperlink JavaScript

Fig 7-1: Hyperlink JavaScript sizes
Size rangeFrequency Size rangeFrequency Size rangeFrequency
=03,026,752>5000 && <=6000515 >14000 && <=1600081
>0 && <= 500442,377>6000 && <=7000372 >16000 && <=1800046
>500 && <=100022,084>7000 && <=8000174 >18000 && <=2000038
>1000 && <=200010,515>8000 && <=9000145 >20000 && <=2500048
>2000 && <=30003,287>9000 && <=10000119 >25000 && <=3000024
>3000 && <=40001468>10000 && <=12000143 >30000 && <=3500024
>4000 && <=5000815>12000 && <=1400078 >3500075

Maximum sizes of hyperlink JavaScript

Fig 7-2: URLs with the largest Hyperlink JavaScript sizes
URLHyperlink
JavaScript
size (chars)
http://www.xocoxoco.dk/ (not available anymore)589,097
http://itsandil.rediffiland.com/iland/itsandil.html212,928
http://www.star-academy.info/211,069
http://www008.upp.so-net.ne.jp/tarch/ (not available anymore)157,194

This article is licensed under a Creative Commons Attribution, Non Commercial - Share Alike 2.5 license.

Comments

The forum archive of this article is still available on My Opera.

No new comments accepted.