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.

B-table data loading very slow

See original GitHub issue

I’m using Laravel and Vue for a project I’m working on. Within my dashboard I’m using BootstrapVue’s datatable named B-table, which receives JSON data from my API.

The API currently only returns 1 user, however it takes quite some time to load it even though it’s just 1 row. I created this GIF to show you it’s loading time when refreshing the webpage:

I’m using Axios to receive data from my API, I’m very curious what’s causing it to be this slow. Here is my code:

<template>
    <div>
        <div id="main-wrapper" class="container">
            <div class="row">
                <div class="col-md-12">
                    <hr>
                    <b-table busy.sync="true" show-empty striped hover responsive :items="users" :fields="fields" :filter="filter" :current-page="currentPage" :per-page="perPage" @refreshed="verfris">
                        <template slot="actions" slot-scope="data">
                            <a class="icon" href="#"><i class="fas fa-eye"></i></a>
                            <a class="icon" href="#"><i class="fas fa-pencil-alt"></i></a>
                            <a class="icon"><i class="fas fa-trash"></i></a>
                        </template>
                    </b-table>
                    <b-pagination :total-rows="totalRows" :per-page="perPage" v-model="currentPage" class="my-0 pagination-sm" />
                </div>

            </div>

        </div>
    </div>
</template>
<script>
    export default {

        data() {
            return {
                users: [],
                filter: null,
                currentPage: 1,
                perPage: 10,
                totalRows: null,
                selectedID: null,
                fields: [
                    {
                        key: 'id',
                        sortable: true
                    },
                    {
                        key: 'name',
                        sortable: true
                    },
                    {
                        key: 'email',
                        sortable: true
                    },
                    {
                        key: 'actions'
                    }

                ],
            }
        },
        mounted() {
            this.getResults();
        },
        methods: {
            // Our method to GET results from a Laravel endpoint
            getResults(ctx, callback) {
                axios.get('/api/users')

                    .then(response => {
                        this.users = response.data;
                        this.totalRows = response.data.length;
                        return this.users;
                    });
            }
        },

    }
</script>

And the JSON data my API returns:

[ { "id": 1, "name": "test", "email": "user@user.nl", "email_verified_at": null, "created_at": "2018-09-28 16:04:36", "updated_at": "2018-09-28 16:04:36" } ]

What can I do to solve this loadtime issue? I’m using an Ubuntu server in VirtualBox.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
tmorehousecommented, Nov 9, 2018

There is also another nifty Vue plugin called vue-async-computed https://github.com/foxbenjaminfox/vue-async-computed (available on NPM as well)

Which allows you to create computed properties that can fetch data.

1reaction
sschadwickcommented, Nov 9, 2018

Not sure if this is within your scope of consideration, however Nuxt.js offers an attractive solution.

Nuxt.js creates an asyncData method within components, which allows a promise to be resolved before the component renders. To the end-user, the data appears to always be present in the table (once the page renders).

https://nuxtjs.org/guide/async-data

Read more comments on GitHub >

github_iconTop Results From Across the Web

Loading time of the datatable is very slow
I have a table with more than three hundred thousand rows and using Server-side processing, however, it takes three minutes to process the...
Read more >
DataTable became very slow! - Laracasts
I'm using dataTable in my project and it's working fine. But when the amount of data is thousand plus or more, it's becoming...
Read more >
Data Table taking 20 seconds to load
This always worked nice but, after add two more columns in the view, the screen got very very slow and the table is...
Read more >
jQuery datatables plugin too slow - need a replacement
This is a problem for huge tables. Lot of users have that plugin and it unknowingly slows their loading of large tables. There...
Read more >
Data loading too slowly | ThoughtSpot Software
If your data is loading slowly, there are a few things you can do to fix it. Some tables may take an unusually...
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