Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6869617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:34:49+00:00 2026-05-27T03:34:49+00:00

I have a div that is not contentEditable. I capture keystrokes, insert the associated

  • 0

I have a div that is not contentEditable. I capture keystrokes, insert the associated char into a string in memory, and then call a render() function that replaces the innerHTML of the div with the current string.

My question is, why does this loop get slower and slower as the innerHTML get’s larger? All I’m doing is overwriting the innerHTML of the div with a straight string. Shouldn’t this be constant time?

dojo.byId('thisFrame').innerHTML = this.value.string;

I don’t understand how this is dependent on the size of the string at all. It slows down when the string’s length gets over about 200 characters, and slows down drastically from there on out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:34:49+00:00Added an answer on May 27, 2026 at 3:34 am
    dojo.byId('thisFrame')
    

    is a DOM element. Setting the innerHTML property of a DOm element is not constant time because it causes a side effect which does not take constant time.

    Specifically, assigning to myHTMLElement.innerHTML causes the browser to parse the string with its HTML parser and rewrite a chunk of the DOM.

    http://www.w3.org/TR/2008/WD-html5-20080610/dom.html#innerhtml0

    On setting, [innerHTML] replaces the node’s children with new nodes that result from parsing the given value.

    Parsing HTML is at least linear in the amount of HTML, and replacing the DOM is at least linear in both the number of nodes removed and the number of nodes added.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application that uses a div that is not contentEditable. Instead,
I have a div that I want to toggle between displaying or not when
I have a <div> that has contentEditable=true . When I copy-paste content within the
I have a div that is divided into two parts. left and right. it
I have a contentEditable div where I want to insert HTML tags (a simple
I have a <div contenteditable=true> that I am trying to use to get text
I have a div that has it's opacity set to 60. Inside the div,
I have a DIV that I want to touch the bottom of the screen
I have a div that's set to overflow: auto; . This contents of this
I have a div that I have bound the jQuery hover event to activate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.