npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

html-engine

v1.0.1

Published

An html middleware between browser and web-backend.

Downloads

2

Readme

html-engine

An html middleware between browser and web-backend.

Usage

  1. cnpm install @froad/html-hengine

HTML Engine 设计文档


HTML Engine 是基于nodejs的一套页面直出引擎。下面将通过以下几点来介绍基于HTML Engine的设计和优点。

  1. 架构和流程图
  2. 为什么要用HTML Engine
  3. Q&A

架构和流程图

HTML Engine

  1. 用户打开页面。
  2. nginx接入,将请求透传给htmlEngine nodejs后台。
  3. htmlEngine加载本地模板文件,并向后台请求数据。
  4. 后台将数据返回给htmlEngine。
  5. htmlEngine将数据和模板进行拼接成完整的html, 并返回给nginx。
  6. nginx将html文件返回给客户端。
  7. 返回给用户的已经是一个有完整内容的html文件。不需要再次ajax请求动态内容。

为什么要用HTML Engine

  1. 看见首屏的速度更快

在HTML Engine中间层已经将动态内容生成html直出给客户端了,省去了多次ajax请求时间(多个RTT时间远大于HTML Engine中间层请求后台的时间,基本就是秒级优化到了毫秒级)。

  1. 前后端完全解耦

后端只用关心数据层面,而不必关心页面view层逻辑和UI。

  1. 解耦后,view层前端可做更多优化

view层前端维护之后,省掉了传统的套页面的沟通和维护成本。并且方便前端自动化构建以及细节优化(如缓存细化到文件级别)。

  1. 和浏览器可以共享js 模板

nodejs的模板和浏览器可以无障碍完全共享(因为都是JS语言)。所以只用维护一套模板。减少出错率和降低维护成本。

  1. nodejs并发率高

Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz 单核 1000并发,10000请求,QPS可达1800+。

Q&A

  1. 跟之前Java直出有什么区别?
  1. 第4条,省去了维护多套模板。
  2. 并且第2, 3条,由前端同学用熟悉的JS来写view直出,省掉了套页面的沟通成本,且方便后续的页面加载优化。
  1. 和加载简易html页面,再通过ajax来动态加载首屏数据有什么区别?
  1. 第1条,用户能更快看到首屏。HTML Engine做为中间层,内网请求一次后台数据花费在 50ms 以下。然后便可以给用户全量的首屏数据。而加载简易html再ajax请求。 一次ajax需要 几百毫秒到几秒 时间。并且对于移动端来说,因为网络不稳定,请求多了容易出现网络错误。
  1. 这种模式有什么缺点吗?

给前端同学带来了新的运维压力。虽然同是js,但是基于服务端的程序,给前端同学带来了新的挑战,如之前很少关注的内存泄漏,优化unix参数等。

more

更多前后端分离背景。

  1. Nicholas Zakas: nodejs and new web front end
  2. 美团全栈之路