I wrote an emoji keyboard online (maybe called it emoji picker, emoji selector) at https://www.emojionline.org. Everything works ok, but there is one problem for memory optimization. My data is stored in an json file. It has 2000 records (size 600kb). I use ajax to load it into memory:
function loadData(){
json = (function () {
json = null;
$.ajax({
'async': false,
'global': false,
'url': 'data.json',
'dataType': "json",
'success': function (data) {
json = data;
}
});
return json;
})();
} And on ready event of document, I called it.
$(document).read(function(e){var data = loadData();});
Everything works well on PC, Mac and smartphone with high RAM (>=GB). For weaker devices, I feel it works bad. Sometime, if the connection is low, I got the message ".... the page need to be reloaded". I understand that to hold a big json file in memory is not good processing. But I need this data for processing. What can I do to do in this situation? I just use jquery, js, html, css. No dynamic languages for web, such as PHP, Java... in this situation are recommended.
I found the solution, but I don't know this is good or not. For me, it really reduce time loading. The solution is: embbed the data into html file. Use external files always make more requests and reduce performance.