[英]Express/Pug. Server side rendering vs client side rendering
I am kind of confused when it comes down to what is client-side and what is server-side. 当涉及到客户端和服务器端时,我会感到困惑。 I am currently building a website, using Pug for my HTML pages, no HTML pages with
<script src="myscripts.js"></script>
etc. 我目前正在建立一个网站,将Pug用于我的HTML页面,没有带有
<script src="myscripts.js"></script>
等的HTML页面。
So am i rendering my pages Server side, since i don't have any files being loaded in the clients browser? 那我是否在服务器端渲染页面,因为我没有在客户端浏览器中加载任何文件? Or is it client side, since the Client can click around and see things being updated?
还是客户端,因为客户端可以单击并查看正在更新的内容?
I think what confuses me, is that normally when i build in Java i have HTML pages with scripts in them. 我认为让我感到困惑的是,通常当我使用Java构建时,我的HTML页面中包含脚本。 But since i am building both front and backend in Javascript, it's kind of hard for me to understand who is rendering what.
但是由于我正在用Javascript来构建前端和后端,所以我很难理解谁在渲染什么。
I apologize if it's a huge noob question, but i would really like to understand it once and for all. 如果这是一个很大的菜鸟问题,我深表歉意,但我真的很想一劳永逸地理解它。
Thanks in advance. 提前致谢。
The scripts inside of <script>
Tags are loaded by the client, and the JavaScript is also run by them. <script>
标记内的<script>
由客户端加载,并且JavaScript也由它们运行。
What the server does is compile Pug to HTML so the client can display it. 服务器要做的是将Pug编译为HTML,以便客户端可以显示它。
If the client clicks something and it changes that is likely some front-end framework that is actively changing the DOM 如果客户端单击某些东西并且它发生更改,则可能是某些前端框架正在主动更改DOM
在您的情况下,它是服务器端渲染,因为服务器将Pug编译为HTML然后将其发送到客户端(已完成HTML),这与客户端框架(如angular,react,vue)不同,在HTML页面上,HTML页面在客户端(浏览器)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.