How to prevent several languages loading

How to prevent several languages loading

djcaesar9114djcaesar9114 Posts: 1Questions: 1Answers: 0

Hello,
When I have several tables, datatables loads for each of them the JSON file of the language, even if it's the same. Isn't it possible to load the JSON file only once?
Thanks :)

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    Currently they aren't shared between instances. That is an issue I'm aware of and it needs to be addressed, but at the moment what you would need to do is Ajax load the language file yourself and then use that with the language option - e.g.:

    $.ajax( {
      url: '/something.lang.json',
      success: function (json) {
        $('#myTable1').DataTable( {
          language: json
        } );
    
        $('#myTable2').DataTable( {
          language: json
        } );
      }
    } );
    

    Not ideal I know, but that's where it is at just now.

    Allan

This discussion has been closed.