"Dealing with sluggishness in Angular 6 when working with large tables

Could anyone offer some insights on the performance issues I am facing with Angular 6? My page contains a large table with 100 rows and 100 columns each. Despite not having any data exchange with the table, using libraries like ng-select or ng-bootstrap datepicker results in lag when interacting with them. For example, even if the ng-select dropdown is empty, it takes about half a second to open and close. The same laggy behavior occurs with other libraries as well. Interestingly, reducing the table size to just 10 rows significantly improves the lag issue. Why might this be happening?

I've noticed that when I opt for native HTML tags such as select option, there is no lag at all - everything reacts instantly. How can I enhance the performance in my specific scenario? Appreciate any guidance! Here's a snippet of the code:

app-component:

<ng-select></ng-select>
<row-component *ngFor="let basket of baskets"></row-component>

row-component:

<div *ngFor="let apple of apples">
    blah blah blah
</div>

Answer №1

  1. Perhaps the issue lies in the number of DOM elements being generated and shown on the page. Implementing row virtualization, which only renders rows visible on the screen, could potentially improve performance.
  2. The observation that using ng-select causes more lag compared to native HTML tags suggests that the additional event listeners from Angular components may be contributing to the webpage's decreased performance.

You may find Ag-Grid's insightful article on optimizing table display entries helpful: https://www.ag-grid.com/ag-grid-performance-hacks/

Answer №2

Have you considered incorporating a library like Angular Material for your table needs? One effective approach, widely used in such cases, is implementing virtual scrolling: Learn more about virtual scrolling here

Answer №3

Before moving forward, there are a few considerations to take into account:

First and foremost, is it necessary to display all 100 columns simultaneously? Perhaps dividing the columns into smaller groups and utilizing a tabbed interface (such as the Angular Bootstrap Tabset ) could help organize the information more effectively. Grouping related columns into tabs can minimize the number of columns visible on one page.

Secondly, performance may become an issue when dealing with a high number of rows. Implementing data paging could be a viable solution (consider exploring Bootstrap paging ). You could establish a fixed limit, such as 40 rows per page, or dynamically determine the row limit based on factors like browser window size and available space for menus. By calculating how many rows can fit on the screen without scrolling, you can optimize performance by displaying only a subset of columns and rows at a time, leading to a significant improvement in overall efficiency.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Struggling with dragging Vue.js modals?

I am currently utilizing the vue-js-modal library, and I'm encountering an issue with it. Whenever I set my modal to be draggable by using :draggable="true", I can drag it around but then I am unable to input any text in the form fields. It seems to c ...

The `createAction` function does not preserve the data type when used with `ofType`

I'm currently developing a mobile application that allows users to choose snacks from a list of available options retrieved from an external API. To handle actions and dispatch API requests, I am utilizing redux-observable. Below is my existing code, ...

Leveraging RXJS for efficient data retrieval in nodejs

When dealing with sending a bulk of data and moving on to the next one upon completion, it can be quite challenging. Take for instance this function: async function test() { await sample.sampleStructure() await sample.sampleDataAdd() await sample.sa ...

Transmit JSON information from one webpage and dynamically retrieve it from another page via AJAX while both pages are active

I am attempting to transfer JSON data from page1 when the submit button is clicked and then retrieve this data dynamically from page2 using AJAX in order to display it in the console. I am unsure of the correct syntax to accomplish this task. There was a s ...

Ways to differentiate among various jasmine.Ajax.stubRequest invocations

I am facing a challenge with my testing setup where I have a series of tests that utilize knockout validation. Before calling the API that I intend to test, a check for a valid email is implemented. jasmine.Ajax.stubRequest('/api/register/').and ...

"Encountered an error with resolving the dependency tree during the installation of npm react-facebook-login, known as ERESOLVE

Having trouble installing npm react-facebook-login in my react application due to dependency errors. It's a bit daunting, and I'm hesitant to forcefully install something that could lead to issues down the line. Since I am new to JavaScript, what ...

Should every component be imported in app.module.ts?

Let's say I have three components: componentA, componentB, componentC. Is it necessary to import all three components? Why or why not? For example, in the following section of code in app.module.ts: app.module.ts @NgModule({ declarations: [** ...

Convert Python strings into HTML JavaScript blocks using Jinja2

Having trouble passing a string to an HTML page in the "<script>" block. I am currently using Python, Flask, and Jinja2. Python code: def foo(): return myString #"[{title: 'Treino 7-Corrida',start: '2015-12-08',color: '#d ...

Having trouble accessing variables using the put method in Laravel with XMLHttpRequest

I am struggling to save my image data using XMLHttpRequest. Although I can send json data and see them in the developer console, I am unable to access them on the server side as the $request appears to be null. Below are snippets of my JavaScript code: ...

The setInterval function for the automated image slider is experiencing issues and is not functioning properly

I am facing an issue where the third photo in the slider does not appear initially. Eventually, the slide fails completely, causing the photos to change rapidly. Strangely, after the slide fails, the third photo sometimes appears sporadically. I am puzzl ...

Ignoring the incremented value in a jQuery function

I have been struggling to resolve this issue for quite some time now, and unfortunately, my lack of proficiency in javascript is hindering me. Here's a jfiddle with an interesting jquery code snippet that I came across: [html] <button id="addPro ...

What is a more efficient way to avoid duplicating code in javascript?

Is there a way to avoid repeating the same code for different feeds? I have 8 feeds that I would like to use and currently, I am just incrementing variable names and feed URLs. <script type="text/javascript> function showFeed(data, content ...

What's causing these divs to be misaligned in various directions?

I am currently working with a front-end framework based on flexbox called Material-UI, and I have noticed that the layout of certain components, particularly the quantity control elements, appears to be different even though they all share the same styling ...

Make sure to execute a function prior to the ajax beforeSend

Before I upload a file using 'fileuploader', I attempted to check the file first in my beforeSend function: beforeSend: function(item, listEl, parentEl, newInputEl, inputEl) { var file = item.file; let readfile = functio ...

"Users have reported that the file upload preview feature in Angular 6 only works after the

I am currently utilizing Angular 6. In my application, I have a simple input type="file" field that passes data to an image source which displays the image I intend to upload. The issue I am facing is that when I select an image for the first time, nothi ...

One way to display the contents of a div after the CSS has finished loading

Here is the code snippet that I am currently working with: $.ajax({ type: 'GET', url: 'url.php', success: function(data){ $("div#mainclass").hide().html(data).fadeIn(100); } }); After implementing this code, I ...

Retrieve the status of the webpage using the "document.readyState" command within the JMeter WebDriver Sampler with JavaScript

I am relatively new to Selenium and WDS in Jmeter, so I could use some assistance. I'm having trouble writing code that waits for the entire page to load. I came across something like "return document.readyState", but I can't seem to implement it ...

Basic calculation of movement yields inaccurate outcome

I am encountering an issue with this specific function implementation. Calculations.add(this, //CONTEXT function () { //CALUCATE this.position.x += (this.movementSpeed.x / 10); }, function () { //HAVE CALCULATED ...

Display the component only if the image source is legitimate

Before rendering an Image component, I want to ensure that the URL is valid and not broken. My current approach seems error-free and the onload function is functioning properly. However, I suspect there might be an issue with how I am handling the return ...

Tips for setting up a typeorm entity with attention to its nullable fields

How can I assign values to typeorm entities and insert them into the database? import { PricingPatternElement } from file const Element:PricingPatternElement = { displayOrder: 10, elementName: "test", createdAt : getCurrentDate(), createdBy: &qu ...