Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 5. Faster, Simpler, More Fun > Updating the DOM Faster with .innerHTML

5.15. Updating the DOM Faster with .innerHTML

5.15.1. Problem

You’re creating a large block of HTML code and using $('#mydiv').html(myhtml); to insert it into the DOM. You’ve profiled the code and found that the .html() method is taking longer than expected.

5.15.2. Solution

Use $('#mydiv')[0].innerHTML = myhtml; for faster DOM updates—if you don’t require any of the special processing that .html() provides.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial