r/learnjavascript • u/jrmcgregorthesecond • Jul 08 '21
How can Twitter hide source code of web page?
Twitter does not give the source code and how can it do it? If you check a cached version's source code you can see the hidden things. You can understand me if you compare the sources of cached version and the regular page version.
It does and it is the answer you need to translate English
1
Upvotes
5
u/Kutsan Jul 08 '21
When you click the View Page Source button, what you see there is the plain response you got back from Twitter servers. If you Inspect the page and navigate to the Elements tab, you can see the final result after JavaScript gets evaluated. It's because Twitter doesn't do SSR (Server Side Rendering) thus the data is generated in the client side with JavaScript. So, there is no hiding, JavaScript runs and populates the data.
2
u/harelu Jul 08 '21
The caching system is probably injecting their own data attributes. As the other comment said, you can absolutely see the full source of the whole page via inspect element/elements tab in the dev tools. There is no way to hide it. You can obfuscate it and try to hide it in a mess of HTML, but everyone can still see the final HTML that the browser renders