laravel table loading slow
laravel table loading slow
cmplus
Posts: 65Questions: 13Answers: 0
Good morning everyone. I'm trying to speed up the loading of a table containing about 5000 values with 42 columns, I haven't managed to do it yet, the loading is really slow. The colvis button doesn't even appear and if I enter
processing: true,
serverSide: true,
The search panel disappears, what did I do wrong with the code I'm trying to use?
@push('scripts')
<script>
$(document).ready(function () {
var table = $('table.display').DataTable({
dom: "<'row'<'col-sm-12'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-12'Q>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-12'P>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: {
url: "//cdn.datatables.net/plug-ins/1.13.1/i18n/it-IT.json"
},
buttons:[
{
extend: 'colvis',
postfixButtons: [ 'colvisRestore' ]
},
{
extend: 'copyHtml5',
text: 'Copia',
titleAttr: 'Copia',
className: 'btn'
},
{
extend: 'csvHtml5',
text: 'CSV',
titleAttr: 'CSV',
className: 'btn '
},
{
extend: 'excelHtml5',
text: 'Excel',
titleAttr: 'Excel',
className: 'btn '
},
{
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'LEGAL',
text: 'PDF',
titleAttr: 'PDF',
className: 'btn '
},
{
extend: 'print',
text: 'Print',
titleAttr: 'Print',
className: 'btn '
}
],
responsive: true,
lengthChange: true,
orderCellsTop: true,
fixedHeader: true,
searchBuilder: true,
buttons: true,
RowGroup: true,
select: true,
searchPanes: true,
});
});
</script>
@endpush
This question has an accepted answers - jump to answer
Answers
All the data is being generated in the page, and not retreved by the
ajax
option. It would be worth profiling to see whether the delay is in generating the page as that would also be the database query as well (just remove or comment out the DataTables initialisation), or whether the page is created fast but the delay is when DataTables initialises.Colin
I tried but the problem is when datatables loads the data it slows everything down, I tried to insert this too but it doesn't change the result
In the controller I put a simple recall maybe I should change the controller
Can you give us a link to the page so we can profile it and get a better idea of where changes might need to be made to speed things up for you?
Allan
So, just to be clear, if DataTables isn't being initialised, the page loads a standard HTML table quickly? If that's the case, you could try a few options. This section of the FAQ should help, it discusses various techniques to improve performance,
Colin