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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@tanshenghu/server-render

v1.0.3

Published

网站服务端渲染(Server Render)

Readme

server-render


说明:

  • 周末闲得蛋疼就写了一个 服务端渲染 服务,底层是基于我之前写的工具@tanshenghu/http开发而来
  • 应该是在疫情被隔离期间,都好几年前就已经开发过这款工具,当时没有开放,只是内部运用,主要是用于门户网站开发,给商家做企业宣传网站所用
  1. 不同于 Next.js Nuxt.js 项目体积大、耗性能、存在浏览器兼容性
  2. 前端界面没有兼容性问题,用jQuery开发PC网站,zepto开发H5,IE6都可以支持,性能绝对杠杠的
  3. 支持响应式H5、PC两个端,两个端两套代码结构但是URL是相同,能做到自动获取对应页面模板
  4. 支持html文件缓存,提高速度,缓解后端数据接口的频繁调用(注意,只有公开页面才能缓存,如遇用户专属信息展示的界面不能缓存,所以开发人员自己要把配置把控好)
  5. html文件缓存支持长期缓存定时缓存(毫秒为单位)无缓存通过接口手动就能清除缓存
  6. 功能非常类似于十几二十年前的 jsp、velocity、php、asp 等等那个年代经典的MVC混合模式开发

总结一点:

  • 其实技术没有绝对的好与坏之分,也没有最好的框架与最差的框架,结合项目而言只有合不合适之说
  • 作为开发人员要根据需求及应用场景,选择合适的技术栈
简单大致的目录结构如下:

├─config
|   ├─index.js   // 项目配置文件
├─controllers
|   ├─h5.js   // H5端界面访问的控制器
|   ├─pc.js   // PC端界面访问的控制器(如果PC的某些控制器与H5差不多一样,可以统一走PC的控制器)
├─models
|   ├─index.js   // 定义后端数据接口调用配置文件
├─views
|   ├─h5
|   |   └index.html   // H5端项目页面文件
|   ├─pc
|   |   └index.html   // PC端项目页面文件
|   ├─public
|   |   └common.js   // 公共资源文件,一般用于PC与H5两边都能通用的场景
├─utils
|   ├─index.js   // 工具方法集合
├─package.json
├─node_modules

Run Demo

DOWNLOAD DEMO: https://mytsh.oss-cn-beijing.aliyuncs.com/files/ssr_demo.zip

CHANGELOG

  • 1.0.0
  1. 首版发布 feat: 2025-11-11 11:00
  • 1.0.1
  1. 主要是功能优化以及功能的扩展 feat: 2025-11-12 18:35
  • 1.0.2
  1. intercept.js文件中扩展onPath路径处理函数,因为整个架子我起始默认情况是考虑PC与H5的。但也有可能部分情况是不需要考虑甚至说没有h5的场景,那这个时候就可以用onPath才处理路径,并返回一个处理之后的新路径,来解决这种需要场景 feat: 2025-11-14 09:08
  • 1.0.3
  1. windows系统环境中由路由映射至文件路径问题的兼容处理 feat: 2025-11-17 20:50

Appreciate

赞赏码

Author

TanShenghu [email protected] (福虎)