last day (23 days later) » 

13:13
@rlemon thank you.
there, now it's your room.
thank you.
you can link a person here, but keep in mind anyone can join and see the conversation
no problem
13:14
adios
https://stackoverflow.com/questions/47924877/what-is-the-best-way-to-show-a-lot-of-json-data-in-a-mobile-app-without-showing?noredirect=1#comment82818046_47924877

Well the JSON data should be decoupled from the view/display. So, you can GET 100 articles with ajax, check network speed in dev tools (I use chrome which has network throttling for mobiles) - if 100 articles takes too long in your opinion for your target speed then you will want to try a smaller amount of articles at a time, e.g. 20, or 5? Test the network speed and see what works best. Multiple ajax GETs are not bad, but if the
I'll b back later.
hello this is zach
thanks george for the time with this
Hi zach im george
no problem
for context, here is my json
loads fine on screen, but of course loading 100 at once is most likely slowing the app down
ive started reading about pagination, etc on how to handle this but this is new to me
im simply teasing out the title and content into a jquery array and putting into the dom. nothing fancy here
13:37
ok so I assume the javascript looks something like:
`ajax.get('http://www.anh-usa.org/wp-admin/admin-ajax.php?&action=return_posts', {contentType:'application/json', dataType:'text', success: function(articles){ /*do stuff */ } });`
and I believe JSON.parse will add a lot of processing time for such a large amount of JSON.
But yes, a solution would be if the JSON was much smaller, if you can make a URL which only requests a smaller chunk of articles, e.g. 5 articles at a time?
If the data source cannot be less than 100 articles, then a different a likely better solution is to use a stream. I suggest using Fetch instead of Ajax: jakearchibald.com/2015/thats-so-fetch/#streams
Once the client has the data you don't want to make any more requests for this data, so make sure of this.
so i can use fetch on json calling?
here is one of my calls - pastebin.com/TEZisM0R
actually one sec
So in simple terms:
1. Reduce amount of JSON requested per request, e.g. to 5 articles (or 10, 20.. please experiment and look at network speed in dev tools F12).
a) Make the JSON data source have a smaller size. If you cannot do this because you don't control the data, go to b.
b) Instead of using ajax to get the JSON data, use a stream such as the Fetch API stream - this allows you can retrieve the articles in chunks.
2) Store in a variable the articles ids which have been loaded, and only request articles which do NOT have the same id as the ones already loaded.
here is the full snippet:
https://pastebin.com/nTM4Gt8u
do you think my code is ok?
13:54
2 mins..
strictly from a coding standpoint, not related to the original topic at hand
one sec let me update it again sorry haha
ok well i have some suggestions although the code is ok..
Fetch is different from ajax so the code will look a bit different. but I will just talk about this code not this topic as you asked...
ive updated it now it checks if array has featured image content, if so then it creates the element div
https://pastebin.com/hGQgsbmy
yes do let me know any suggestions you have on my code in terms of making it cleaner or better
By the way, check out codereview.stackexchange.com
yeah i just hate to dump all my code there seems wasteful of other's time. but i will use it for parts of this
brb
14:02
im gonna make a clone and put my comments in there and then send u that pastebin
not as many changes as i first thought, but took a while to actually edit.. here are my suggestions:
back in 20 minutes
14:40
thanks. i elected to use vanilla JS to create the divs since they are much faster than jQuery on the DOM
is it normal to append all my divs like i am doing with one big ass 'appendChild' vomit?
elAct.appendChild(readContentNode).appendChild(itemFeaturedImage).appendChild(itemContentDiv).appendChild(itemReadMoreLink);
 
2 hours later…
16:14
ive updated the function to use documentFragment - pastebin.com/4dm7Gesb - curious your thoughts
 
1 hour later…
17:42
hey buddy i went ahead and finished the loading of more items. for me it seems fast on the phone. if you have time to look over it let me know if i am doing something stupid here. again it is my first time with JSON and showing content not all at once

https://gist.github.com/zachisit/b1449301cfce4c1e9b5d931d8a15808d
i guess my current issue w/this code is i would need to check somehow if no more array items, and hide load more button
18:36
ok i updated the gist, it now checks if user is at end of array by checking if last item in the UL has class hidden added. if yes, that means user is at end of list/array of data and then we do not need to show load more button.

let me know if you think my solution is ok
 
3 hours later…
21:22
Looks like document fragment is more performant yeah. As for..in loop, these are meant for looping objects and are less efficient on arrays, so I recommend using something like data.forEach(function(article){ ... })
I don't see an issue with chaining appendChild, as long as it works.
21:57
I think the load code you have is unecessarily complicated. here is my untested solution:

  last day (23 days later) »