I am also a supporter of dataURI, as they are the most transparent (client) way to implement data embedding on web pages.
However, they were first used to embed small images and other resources that would impede performance due to connectivity issues as well as
parallel HTTP / 1 download restrictions . The trade-off is delicate because the encoding data, as dataURI can cause (estimate ball) a 30%
increase in data size , but the critical point is where dataURIs stop being useful around the size of small images, which are usually orders of magnitude higher than serialized data.
The critical point here for a single-page application scenario is that to view more than one sample to fetch data.
Embedding data for use by page scripts otherwise static HTML has the following consequences:
- HTML itself cannot be cached (only with a cached copy for each set of embedded data and each version of the page.)
- An entire page (multiple versions) must be generated on a server that also knows how to get data.
- Entered data can block the rendering of pages until the user perceives it (this can be done by embedding the data at the end of the HTML code, but client script execution may have to wait completely, such as displaying the loading indicator, it is more difficult to implement.)
On the other hand, storing data on a separate round trip, despite the journey itself, would be:
- Perhaps your already working implementation, as it is
- Allow clients to use cached HTML and scripts that only need to be updated when the version is actually changed (there was an unsuccessful specification called AppCache for this purpose, now replaced by experimental Service Workers )
- Allow this HTML and scripts to be fully static resources that can be served from dumb CDNs that are faster and closer to the client browser and do not need to query the database or run any server code
All of these are big victories in my opinion, so I recommend seriously considering the need for data implementation, because it can be an early optimization, which can lead to a lot of pain and an actual decrease in performance! Especially because SPDY and now HTTP / 2 are already coming to fix these problems with the return pass and number.
source share