HTC Components with > 512 bytes of javascript slow to unload

From: davedave (google_at_rhoadarmer.com)
Date: 09/22/04


Date: 22 Sep 2004 08:12:25 -0700

When using large number of copies of a lightweight HTC behavior
component that contains more than 512 bytes of javascript code, the
page takes a LONG time to unload the page (such as by closing the
window, refreshing the page, navigating elsewhere, etc). In the
example below, running on my machine, it takes about 0.02 seconds /
component to unload the page, making the component pretty unusable.
If I shrink the javascript code below the 512 byte limit, it will
unload instantly.

The 512 byte limit only affects the contents of the <script
language=javascript></script> section of the behavior. You can have
as many <public:property>, <public:method>, or <public:attach> tags as
you want without affecting unload speed.

This is only a problem when using Javascript or JScript as the
scripting language. Rewritting the component to use VBScript fixes
the problem.

Also, for some silly reason, including a blank <script
language=VBScript></script> before the <script language=javascript>
tag inside the component also fixes the problem.

My environment: IE6 on Win2k with all patches.

The following will unload slowly. Taking out the "Z" in the first
line of javascript code below will fix everything.

MyPage.asp:
-------------------------------
<html>
        <head>
                <style>
                        .MyClass {behavior:url('MyBehavior.htc');
                </style>
        </head>

        <body>
                <%
                for i = 1 to 500
                        Response.Write "<input type=text class=MyClass><br>"
                next
                %>
        </body>
</html>

MyBehavior.htc:
-------------------------------
<public:component lightweight=true>
<script language=javascript>
var Zaaaaaaaa, bbbbbbbbbbbb, cccccccccccccccc, ddddddddddddddddd;
function aaaaaaaaaaaaaaa() {};
function bbbbbbbbbbbb() {};
function cccccccccccccc() {};
function ddddddddddddddddddd() {};
function eeeeeeeeeeeeee() {};
function ffffffffffffffffffff() {};
function ggggggggggggggggg() {};
function hhhhhhhhhhhhhhh() {};
function iiiiiiiiiiiiii() {};
function jjjjjjjjjjjjjjjjj() {};
function kkkkkkkkkkkk() {};
function llllllllll() {};
function mmmmmmmmmmmmmmmm() {};
function zzzzzzzzzz1() {};
</script>
</public:component>

this version of MyBehavior.htc works fine:
-------------------------------
<public:component lightweight=true>
<script language=javascript>
var aaaaaaaa, bbbbbbbbbbbb, cccccccccccccccc, ddddddddddddddddd;
function aaaaaaaaaaaaaaa() {};
function bbbbbbbbbbbb() {};
function cccccccccccccc() {};
function ddddddddddddddddddd() {};
function eeeeeeeeeeeeee() {};
function ffffffffffffffffffff() {};
function ggggggggggggggggg() {};
function hhhhhhhhhhhhhhh() {};
function iiiiiiiiiiiiii() {};
function jjjjjjjjjjjjjjjjj() {};
function kkkkkkkkkkkk() {};
function llllllllll() {};
function mmmmmmmmmmmmmmmm() {};
function zzzzzzzzzz1() {};
</script>
</public:component>

and for some silly reason, this works fine:
-------------------------------
<public:component lightweight=true>
<script language=VBScript></script>
<script language=javascript>
var Zaaaaaaaa, bbbbbbbbbbbb, cccccccccccccccc, ddddddddddddddddd;
function aaaaaaaaaaaaaaa() {};
function bbbbbbbbbbbb() {};
function cccccccccccccc() {};
function ddddddddddddddddddd() {};
function eeeeeeeeeeeeee() {};
function ffffffffffffffffffff() {};
function ggggggggggggggggg() {};
function hhhhhhhhhhhhhhh() {};
function iiiiiiiiiiiiii() {};
function jjjjjjjjjjjjjjjjj() {};
function kkkkkkkkkkkk() {};
function llllllllll() {};
function mmmmmmmmmmmmmmmm() {};
function zzzzzzzzzz1() {};
</script>
</public:component>



Relevant Pages

  • Re: HTC Components with > 512 bytes of javascript slow to unload
    ... <script language=javascript> ... > component that contains more than 512 bytes of javascript code, ... > component to unload the page, ... > var Zaaaaaaaa, bbbbbbbbbbbb, cccccccccccccccc, ddddddddddddddddd; ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • [CFT][RFC] Module auto-unloading solution.
    ... I put together the script at the end of this ... It won't try to unload ethernet drivers ... ## your kernel modules. ... # Create a regexp of ethernet modules. ...
    (Linux-Kernel)
  • Re: 2 simple questions about SKILL language
    ... how to undefine it without exiting icfb? ... You cannot "unload" a script. ...
    (comp.cad.cadence)
  • Re: Email obfuscation programs
    ... > script into your correct address ... then View Source in IE to see the javascript code they use. ... Tom Koch - MVP for Internet Explorer and Outlook Express ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: Javascript Tutorial
    ... (JavaScript code goes in here) ... With regards to "older browsers that do not understand script" and the commenting of code. ... There are more but I stopped reading about 1/3rd through the page. ...
    (comp.lang.javascript)