question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Performance : Prevent DOM reflow on import preview

See original GitHub issue

Currently, when the import preview is huge (i.e. thousands of rows), it forces the browser to do substantial DOM reflow. This greatly slows down the browser as it tries to resize the preview table (and the whole page) over and over again as it prints new DOM elements.

To improve performance, you can set table.import-preview’s display to none first, and then set it to table later on after the whole table has been loaded.

That is, add this before the table is loaded

<style>
  table.import-preview {
    display:none;
  }
</style>

(or add this in import.css), and then add at the end of import_export/import.html

  <script type="text/javascript">
    (function() {
      var import_previews = document.querySelectorAll('table.import-preview')
      for (var i = 0; i < import_previews.length; i++) {
        import_previews[i].style.display = 'table'
      }
    })();
  </script>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
franz-seecommented, Mar 26, 2019

@bmihelac i’ll try that out and will let you know how it goes 😃 thanks !

1reaction
franz-seecommented, Mar 26, 2019

@andrewgy8 the down side is if javascript is disabled, then the preview will never show up 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Web Performance: Minimising DOM Reflow / Layout Shift
In this article, I will be listing a few ways by which a DOM reflow / layout shift event might occur, why it's...
Read more >
10 Ways to Minimize Reflows and Improve Performance
Adding, removing or changing visible DOM elements. The first is obvious; using JavaScript to change the DOM will cause a reflow.
Read more >
Methods Of Improving And Optimizing Performance In React ...
Analyzing React Components With Chrome's Performance Tab # · Disable all extensions temporarily, especially React Developer Tools, because they ...
Read more >
Lightning Components Performance Best Practices
In this blog post, we discuss how these characteristics impact performance, and review a list of best practices to optimize the performance ......
Read more >
Make Webpages Load Faster with Lazy Loading - Infinum
Avoiding Content Reflow ... When an image is yet to be downloaded, the browser doesn't know the size it will take up. Then...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found