Re: Menu and javascript error message in Mozilla
Alex Russell <[email protected]> Sun, 7 Mar 2004 22:02:53 -0800
| Newsgroups | gmane.comp.windows.devel.netwindows |
|---|---|
| Organization | netWindows.org |
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sunday 07 March 2004 8:02 pm, David Peterson wrote:
> Hello,
>
> At random times I get an error message in Mozilla asking if I wish
> to terminate the execution of a JavaScript that is slowing down the
> browser. This is when I am using the menubar. Why is this
> happening and how can I get rid of it?
netWindows (by default) preforms several somewhat expensive operations
on page load. The most expensive of these is a recursive DOM
traversal of the entire document to search for inline constructor
nodes, which is what I epxect is causing Mozilla to throw up it's
hands and give up.
Fortunantly, this is all configurable, and we provide a way around the
expense of a full traversal without forcing you to give up inline
constructors.
If you have a look at the documentation, there is a section on the
__config__ object. Two properties work togeather to do what we need,
findWidgets and searchIds. Both of these properties are inheritable
from the NWconfig array (if you set one up). The first controls
whether or not a recursive check starting at document.body should be
preformed, and the second provides a set of HTML IDs whose children
should be searched for constructors, regardless of whether or not a
global search is preformed. This means that if you do this:
<script type="text/javascript">
// NOTE: this MUST happen before including netWindows.js
var NWconfig = {};
NWconfig.findWidgets = false;
NWconfig.searchIds = ["foo"];
</script>
<script type="text/javascript"
src="winScripts/netWindows.js"></script>
Then only the elment with an id of "foo" will be searched for inline
ctors.
Soooo, to tie this all togeather, if your inline ctor node for your
node has an ID of "bar", you could combine the previous bits of
information several ways to make your page load faster:
1.) define a "container" div or span element on the page and specify
that only that container should be searched.
2.) if you know the IDs ahead of time, use the syntax outlined above.
3.) if you are using a server-side language to generate your page, you
may want to specify searchIds as an empty array, and keep a list of
them on the server side and at the end of <body>, assign that list of
IDs to searchIds. Another option is to directly add a small <script>
section after every ctor node that appends the ID to the list.
Whichever route you take, note that all of these assignments must
happen _before_ document.onLoad fires in the client environment. This
generally means that inline scripts anywhere are OK, but event-driven
assignment won't be a good thing (since onLoad is the first event to
fire most of the time).
Let me know if you need any more help with this or would like more
examples of how to use this technique.
Regards
- --
Alex Russell
[email protected] BD10 7AFC 87F6 63F9 1691 83FA 9884 3A15 AFC9 61B7
[email protected] F687 1964 1EF6 453E 9BD0 5148 A15D 1D43 AB92 9A46
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)
iD8DBQFATAyNoV0dQ6uSmkYRAlDFAJkBkclGYEhC1WBmQnI1qpQIXOgkugCbBzaq
6HQy6Yj1iqcGlwuOmj378eg=
=CI2D
-----END PGP SIGNATURE-----
_______________________________________________
The netWindows developers list: [email protected]
http://netwindows.org/mailman/listinfo/devel_netwindows.org