In a support thread titled “Odd "data-preloaded" element in HTML,” ChrisGammell reports encountering a large, seemingly unusual block of code labeled data-preloaded in the HTML source of a Discourse forum page. While troubleshooting a subdomain issue, they noticed this block and questioned its purpose and whether it might contain sensitive information. riking explains that this block contains “after-boot” data for the Discourse JavaScript application, allowing the page to render without an additional server request upon hard refresh. It appears on every Discourse page when viewing source or hard-refreshing, but is bypassed during normal navigation (which fetches data dynamically). Not all pages support this preloading — on unsupported ones, the block is empty and a server request is still needed. Regarding security, riking confirms the data is personalized to the logged-in user but contains no sensitive information beyond what the user already has access to. The block is a normal, non-malicious part of Discourse’s performance optimization.
But in the midst of sniffing out bad links, I came upon a very odd feature hidden in the HTML of one of my pages:
In the source, I see a large and odd looking block of code in a “hidden” tag called “data-preloaded”. It seems like a link to a bunch of different things, but honestly, it looks like link stuffing or something odd like that. Two questions:
What is the purpose of this block?
Is there any reason to be concerned about it, like if there would be sensitive information place in there?
Much like when I peek under the hood of my car, I see things that are quite complicated and sometimes messy, but not necessarily broken or nefarious. I’m curious all the same.
This block of data contains the “after-boot” information for the Discourse JS app. When you hard-reload a topic page, the block contains the information needed to render the topic, without contacting the server again.
It’ll show up on every Discourse page when you view source or hard refresh. If you’re navigating around by clicking, though, the block isn’t used and data is fetched dynamically from the server.
Note that not every page actually supports the preload block, so on those pages the content will be empty and a second request to fetch the real data for the page will be required. The important pages support it.
The contents are personalized to you while logged in, yes, but there shouldn’t be any sensitive information that you don’t already have access to.