1

I have read this and this about techniques to pass data from PHP to Javascript, however I am worried about memory and variable size limits in javascript.

Basically I am passing chunks of HTML from PHP to Javascript so that Jquery can output dynamically page sections, but these chunks are getting big (currently a dozen variables are holding some 108k of data totally), so I was wondering what could be a safe and efficient alternative, possibly avoiding Ajax as for performance issues.

At the moment data is passed "echoing" from PHP to HTML/Javascript (not very elegant, I know).

Maybe I could save into files these page chunks and use jQuery .load?

What do you think?

Community
  • 1
  • 1
Riccardo
  • 2,054
  • 6
  • 33
  • 51
  • 3
    108k is (comparatively) nothing. You should be fine. That's no reason not to reduce the amount of data if you can though. Paging and/or filtering the data may be useful. – Rory McCrossan Aug 19 '16 at 10:17
  • 108Ko of data is really not huge and should work properly using Ajax. – AntoineB Aug 19 '16 at 10:17
  • Antoine, I'd like to avoid Ajax – Riccardo Aug 19 '16 at 10:18
  • today 108k with/without assets is not too large. – Iceman Aug 19 '16 at 10:18
  • @Riccardo Then your current way of doing it is fine too. – AntoineB Aug 19 '16 at 10:18
  • @Riccardo why? It's the most appropriate solution. Without it you're stuck having to refresh the page on each request which mean even more bandwidth being used and more work for the server. I'm also confused as you say you don't want to use AJAX, yet suggest `load()`... which uses AJAX – Rory McCrossan Aug 19 '16 at 10:19
  • 108k gzipped / however compressed html is really nothing – PeeHaa Aug 19 '16 at 10:19
  • 2
    I'm voting to close this question as off-topic because it is about *possible* performance issues without having tested whether there are performance issues and whether the question is about the actual bottleneck as such it's near impossible to give an correct answer. – PeeHaa Aug 19 '16 at 10:20
  • Well PeeHaa, you could give your two cents for example to narrow down the context if in your opinion this is too broad – Riccardo Aug 19 '16 at 10:34
  • Thank you everybody for considering the question :-) – Riccardo Aug 19 '16 at 12:19

1 Answers1

-1

Regarding the variable limits, take a look at the following question/answer: Do javascript variables have a storage capacity limit?

Community
  • 1
  • 1
Adnan
  • 517
  • 3
  • 8