This is a general Question开发者_开发百科:
Consider a plain-html page that hast got some elements which can (if the browser supports) be enhanced by javascript. To do so, javascript needs some additional data, e.g. for relation between displayed entities on the plan-html page.
So my question: To get the additional data, should i make an additional xhr-request oder should i put a script-tag at the bottom of my page, where all the data ist already present in javascript code?
Have it in a script tag at the bottom of the page if you can. It's much faster and less strain on your server since you don't have to make an additional request every time. Might increase the page size a bit if there is a LOT of data though
精彩评论