简体   繁体   English

网站如何使用Javascript而不在浏览器中显示任何结构化HTML?

[英]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.

相关问题 如何告诉Chrome,请针对每个网站或任何操作使用浏览器中的本地javascript? 类似于歌剧 - How to tell Chrome, please use local javascript from the browser for every site or any actions? Similar to Opera 如何使用javascript或html为我的网站制作一个跨浏览器友好的文本轮播? - How can I make a text carousel for my site cross browser friendly by using javascript or html? 如何使用结构指令? - How to use a structural directive? 如何在浏览器中使用带有纯 html 和 javascript 的 IPFS - How to use IPFS with pure html and javascript in the browser 如何使用javascript更改html站点的所有URL,以便它们可在子域上工作 - How can I use javascript to change all of the urls of an html site so that they work on a subdomain 如何在浏览器中编辑 javascript,就像我可以使用 Firebug 编辑 CSS/HTML 一样? - How can I edit javascript in my browser like I can use Firebug to edit CSS/HTML? 如何使用 JavaScript 显示 HTML 元素的 id - How to use JavaScript to display id of an HTML element 如何使用Javascript来判断浏览器是否更改了HTML输入字段? - How can I use Javascript to tell whether an HTML input field has been changed by the browser? JavaScript 在 HTML 站点上未按预期显示 - JavaScript doesn't display as intended on HTML Site 是否有任何Javascript API用于查找每个网站在浏览器中存储的数据量? - Is there any Javascript API for finding how much data each site store in the browser?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM