Re: regular expression performance - Mozilla

This is a discussion on Re: regular expression performance - Mozilla ; ----- Original Message ---- > From: Neil > > I think innerHTML is likely to be the slowest part of the process. If > you're really only interested in the text, here are some options I can > think of: ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Re: regular expression performance

  1. Re: regular expression performance



    ----- Original Message ----
    > From: Neil
    >


    > I think innerHTML is likely to be the slowest part of the process. If
    > you're really only interested in the text, here are some options I can
    > think of:
    >
    > * Use .textContent which is basically a concatenation of all the
    > text nodes in the document (whitespace and all)
    > * Create a range that selects the document and use toString to
    > obtain a text representation
    > * Walk the text nodes using a tree walker or xpath evaluator (but
    > this will miss embedded styles e.g. sex)


    Wow, thanks so much for the tips. I don't care about embedded styles.I'll run some profiling tests to see which is fastest, but that of course depends on the page content itself. Do you have any gut feeling as to which of these would be fastest?

    As a point of curiosity, why is .innerHTML "slower" than the above three?




  2. Re: regular expression performance

    Eric H. Jung wrote:

    >As a point of curiosity, why is .innerHTML "slower" than the above three?
    >
    >

    The HTML isn't stored anywhere (well, the source may be cached, but it's
    not mapped to the DOM in any way), so it has to be recreated from the
    DOM tree.

    --
    Warning: May contain traces of nuts.

+ Reply to Thread