News for hackers. Stuff that matters.
Re:JavaScript frameworks and topics to learn in 2017 by count_zero on Sunday December 18, 2016 @02:45PM (#13207223)
I'm experimenting with a hybrid approach, where the server injects a JSON string into a hidden div's data attribute, containing all the data the front end would have traditionally received through an ajax call on initialization.

It's no ideal, as the initial DOM render isn't fully populated, but it's much faster than waiting for another round trip to the server to populate the view.

Here's an example sketch using vue.js (data is in #game-data div): https://game-collector-staging.herokuapp.com/

Re:JavaScript frameworks and topics to learn in 2017 by bigmanwalter on Sunday December 18, 2016 @03:54PM (#13207582)
Or, even better, I just inject the JSON data into a script tag with a var declaration, sort of like:

<script> var models = {{=models}}; </script>

And just like that, I have my data accessible as a global variable.