The used script of the plugin:
<script src="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap4.min.js"></script>
I have a datatable with maximum 19K row of records. I am not using server side processing or AJAX, it is just the DOM. I tried migrating to server side processing, but it is very time consuming to implement all features all over again. it is all about the image resources that have been used per each record, as per my guess which makes the datatable slowest. It is working perfect on local though. The differences of local vs server are below.
The way the table is been implemented, the code block is below.
var tableone= $('#tableX').DataTable({
"scroller": true,
"deferRender": true,
"responsive": true,
"order": [[1, 'asc']],
"paging": true,
"pageLength": 150,
"bFilter": false,
"searching": true,
"rowCallback": function( row, data, index ) {
if ( data[9] == "MATCH COLUMN" )
{
$('td', row).css('background-color', '#b5b5de');
}
else if ( data[9] != "MATCH COLUMN" )
{
$('td', row).css('background-color', 'white');
}
},
"drawCallback": function ( settings ) {
var api = this.api();
var rows = api.rows( {page:'current'} ).nodes();
var last=null;
api.column(1, {page:'current'} ).data().each( function ( group, i ) {
if ( last !== group ) {
$(rows).eq( i ).before(
'<tr class="group"><td class="delBack"colspan="14">'+'<strong> THIS SHOULD BE GROUPIFIED : '+group+'</strong></td></tr>'
);
last = group;
}
} );
},
"autoWidth": false,
"aoColumnDefs": [{ "bSortable": false, "bSearchable": false, "aTargets": [2,4,5,6,7,8,9,10,11,12,13 ] } ],
"aoColumns": [{ "sWidth": "5%" }, { "sWidth": "5%" },{ "sWidth": "2%" }, { "sWidth": "3%" },{ "sWidth": "2%" },{ "sWidth": "19%" },{ "sWidth": "10%" },{ "sWidth": "3%" },{ "sWidth": "3%" },{ "sWidth": "3%" },{ "sWidth": "15%" },{ "sWidth": "5%" },{ "sWidth": "15%" },{"sWidth":"15%"}]
});
I am aware of the DOM, AJAX SOURCE and SSP. But It should be done through clientside and not server. What can be done to improve it's performance with an efficient way to retrieve images or resources if that is what been causing the excessive load. Any suggestion is appreciated.
EDIT - IMAGE UPLOAD
Image would be uploaded as string based in the database, the files would be uploaded to the folder. When the images are retrieved to the datatable it is done as this
$upload_dir = 'uploads/';
<tbody>
<?php
$sql = "SELECT * FROM `product` WHERE `status`= 'New'";
$result = mysqli_query($conn, $sql);
if(mysqli_num_rows($result)){
while($row = mysqli_fetch_assoc($result)) {
<td><img src ="<?php echo $upload_dir.$image ?>" height="30" width="30" data-toggle="modal" data-target="#imagemodal<?php echo $row['id']?>"></td>
<?php
}
?>
Then when the image thumbnail is clicked the full image would be shown in a modal.
EDIT - AFTER REMOVING IMAGE
After removing the image resources, it is not bad. but for 19K records, still 10 SEC. isn't it a bit too much?