←back to thread

217 points palmfacehn | 1 comments | | HN request time: 0s | source
Show context
alserio ◴[] No.45107190[source]
I was wondering, are template elements a good place to store json data in the page to be consumed by js?
replies(4): >>45107213 #>>45107278 #>>45108146 #>>45108459 #
1. Gualdrapo ◴[] No.45108146[source]
For my portfolio (miler.codeberg.page) and the refactor&redesign I'm doing of it (that I hope to finish soon!), I feed some <template>s with data coming from a json that acts like kind of a database. I feel the process of querying nodes and setting their data is still a bit rudimentary in plain JS and it should be a pain in the ass for huge datasets or lots of nodes, but at least with modern JS it is not necessary to fetch the json with a XMLHTTPRequest or something - it can work importing it like a regular JS module, so at least there's that.