[英]How can a site Use Javascript and NOT display any structural HTML in the browser?
http://thelovemagazine.co.uk http://thelovemagazine.co.uk
I have looked at this site's browser source and investigated via Charles Proxy. 我查看了该站点的浏览器源,并通过Charles Proxy进行了调查。 I used Wappalyzer to see what they are using and it looks like Cowboy, Erlang, NodeJS, Express, React and Modernizr.
我使用Wappalyzer来查看他们正在使用什么,它看起来像Cowboy,Erlang,NodeJS,Express,React和Modernizr。
I'm not able to see any structural HTML. 我看不到任何结构化的HTML。 It looks like it's just throwing JavaScript at the browser and using JSON (maybe?) to display the content.
看起来好像只是在浏览器上投放JavaScript并使用JSON(也许是?)来显示内容。 Also the CSS file has very odd class names that are seemingly meaningless like .jkhl4350s
而且CSS文件中的类名称很奇怪,看起来像.jkhl4350s一样毫无意义。
My question is, how are they doing this? 我的问题是,他们如何做到这一点? Perhaps some kind of CMS that is obfuscating things?
也许某种类型的CMS使事情变得混乱了? Can JavaScript render content without HTML structure?
JavaScript可以在没有HTML结构的情况下呈现内容吗?
I'm trying to figure this out because I wanted to see the website structure and how they used to the diff JS libraries. 我想弄清楚这一点,因为我想看看网站的结构以及它们如何用于diff JS库。
I'm stumped and would appreciate any insight. 我很困惑,不胜感激。
Thank you! 谢谢!
My question is, how are they doing this?
我的问题是,他们如何做到这一点?
They're using React , as evidenced by the many data-reactid
attributes you'll see throughout the source code (React creates a declarative model of the user interface, so any time data is changed, the UI is re-rendered to reflect those updates. There are some optimizations behind the scenes, so I'd recommend taking a look at their docs to get a better understanding.) 他们正在使用React ,正如您在整个源代码中将看到的许多
data-reactid
属性所证明的那样(React创建了用户界面的声明性模型,因此,每当数据更改时,UI都会重新呈现以反映这些更新。幕后有一些优化,所以我建议您看一下他们的文档,以更好地理解。)
Can JavaScript render content without HTML structure?
JavaScript可以在没有HTML结构的情况下呈现内容吗?
JavaScript can render DOM elements. JavaScript可以呈现DOM元素。 In React, you'll see it generally in a component's
render
function: 在React中,您通常会在组件的
render
函数中看到它:
render() {
return <div>Something here</div>;
}
very odd class names that are seemingly meaningless like .jkhl4350s
非常奇怪的类名,看起来像.jkhl4350s毫无意义
They're not meaningless at all. 它们根本不是毫无意义的。 They may be using something like CSS modules , which gets rid of the global CSS namespace.
他们可能正在使用CSS模块之类的东西,从而摆脱了全局CSS名称空间。 That's why the class names appear to be a bunch of gibberish.
这就是为什么类名看起来很乱的原因。
I'm trying to figure this out because I wanted to see the website structure and how they used to the diff JS libraries.
我想弄清楚这一点,因为我想看看网站的结构以及它们如何用于diff JS库。
It's going to be very difficult to do that without seeing their pre-compiled source code, so unless their code is open-source somewhere, you'll likely run into difficulties understanding it (as you've pointed out, the compiled code looks a bit strange). 在没有看到其预编译源代码的情况下很难做到这一点,因此,除非他们的代码在某个地方是开源的,否则您可能会难以理解它(如您所指出的那样,编译后的代码看起来像有点怪)。 You'll have better luck looking at the React docs.
查看React文档会更好。
This is a pretty broad question, so I'd recommend starting by reading the documentation in the two links I've provided above. 这是一个相当广泛的问题,因此,我建议您先阅读上面提供的两个链接中的文档。
Via Shadow-DOM : Mozilla Developer Shadow-DOM 通过Shadow-DOM: Mozilla开发人员Shadow-DOM
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.