When using Ajax for the purpose of rerendering a portion of a page with new data, is it better for: A. The endpoint to respond with HTML, which would use more bandwidth but would be able to be inserted into the page immediatelyorB. The endpoint to respond with JSON, which would use less bandwidth but would require HTML to be constructed on the browser
>>108543477network bandwidth is an expensive IO comparatively so just send the json data
>>108543477Whatever is easiest, it's probably a matter of just 2 vs 3 KB so it's negligible
>>108543499What about the fact that the JS file sent to the browser would be bigger since it would need to contain more code?
>>108543549What about it? Please tell us, we're all waiting your underage retarded opinion
>>108543477XML or XHTMLI refuse to elaborate any further
Ajax tongues my anus. Don't do it.
>>108543477Depends how big the HTML ishttps://endtimes.dev/why-your-website-should-be-under-14kb-in-size/
>>108543477As a matter of fact, Rails' ActionCable does point A. It can work if you're not doing very massive page renders but for more complex scenarios, I would definitely prefer B.https://www.cloudbees.com/blog/actioncable-the-missing-guide#partial-content-reloading
>>108543477>I'm going to do client html rendering, for performance!>To do this, I need to server render some jsonnow you have two problems, as they say
>>108543477If you have to do lots of document.createElement() calls, then return HTML - it's easier to manage the UI. If you're just updating a few data points and don't need to do any DOM manipulations(except e.g element.innerText = ....) then return JSON.