Run a Full JavaScript Website with AxonASP — No Node.js Required

Run a Full JavaScript Website with AxonASP — No Node.js Required

使用 AxonASP 运行完整的 JavaScript 网站 — 无需 Node.js

AxonASP is a high-performance Classic ASP engine written in Go — but here’s the twist: it runs JavaScript (JScript) natively on the server side. You get a synchronous, predictable execution model, full ECMAScript 5/6+ support, and zero dependency on Node.js or any third-party JavaScript runtime. And yes — you can build an entire production website with it. AxonASP 是一个用 Go 语言编写的高性能经典 ASP 引擎,但它的独特之处在于:它能在服务器端原生运行 JavaScript (JScript)。你将获得同步且可预测的执行模型、完整的 ECMAScript 5/6+ 支持,并且完全不依赖 Node.js 或任何第三方 JavaScript 运行时。没错,你可以用它构建整个生产环境的网站。

Why AxonASP Changes the Game for Server-Side JS

为什么 AxonASP 改变了服务器端 JS 的游戏规则

Most developers associate server-side JavaScript exclusively with Node.js. And Node.js is great — until you’re drowning in async/await chains, package.json conflicts, and the 47th minor version bump of a dependency that broke your build. AxonASP takes a fundamentally different approach. Instead of wrapping everything in an event loop and forcing asynchronous patterns everywhere, AxonASP’s JavaScript engine executes code synchronously by default. You write your server logic the same way you write your frontend logic — line by line, top to bottom. It compiles through a high-performance AST parser and runs directly on a custom Go-based virtual machine. The result? Cleaner code, simpler debugging, and a massive reduction in cognitive overhead. 大多数开发者将服务器端 JavaScript 与 Node.js 划等号。Node.js 很棒,但当你陷入 async/await 链、package.json 冲突,以及第 47 次因依赖项小版本更新导致构建失败时,它就变得令人头疼。AxonASP 采取了截然不同的方法。它没有将一切包裹在事件循环中并强制使用异步模式,而是默认同步执行代码。你编写服务器逻辑的方式与编写前端逻辑完全一致——逐行执行,从上到下。它通过高性能 AST 解析器进行编译,并直接在自定义的 Go 虚拟机上运行。结果如何?代码更整洁,调试更简单,认知负担大幅降低。

What You Get Out of the Box

开箱即用的功能

  • Full ES5 + ES6 support: (classes, arrow functions, template literals, destructuring, proxies, for…of, Map, Set, Symbol, typed arrays — 37+ modern features documented)
  • 完整的 ES5 + ES6 支持:(类、箭头函数、模板字符串、解构赋值、代理、for…of、Map、Set、Symbol、类型化数组——记录在案的 37+ 种现代特性)
  • Synchronous execution: no callback pyramid, no promise chains for basic I/O.
  • 同步执行: 没有回调地狱,基础 I/O 操作无需 Promise 链。
  • ASP intrinsic objects: Request, Response, Session, Application, Server — all accessible directly from your JS code.
  • ASP 内置对象: Request、Response、Session、Application、Server——均可直接从 JS 代码中访问。
  • No npm install required: just write .asp or .js files and point the server at them.
  • 无需 npm install: 只需编写 .asp 或 .js 文件,并将服务器指向它们即可。
  • CLI execution: run JavaScript files from the command line for automation, batch processing, or testing.
  • CLI 执行: 可从命令行运行 JavaScript 文件,用于自动化、批处理或测试。

The Philosophy: Simplicity Over Complexity

哲学:简单胜过复杂

Here’s a hard truth: most web applications don’t need 2,000 npm modules. They need to read a database, render HTML, handle form submissions, and maybe serve a JSON API. That’s it. The modern JavaScript ecosystem has convinced people that every project requires a build pipeline, a bundler, a linter, a type checker, and a module graph resolver. But the reality is that a well-structured server-rendered application — where you can see the actual HTML structure of your pages and inject backend logic only where you need it — is often simpler, faster, and more maintainable than a single-page application backed by a microservice mesh. With AxonASP, you write plain HTML with embedded server-side JavaScript. The <% %> delimiters mark exactly where the backend logic lives. You can see the entire page structure in one file. No hidden abstraction layers. No magic. 一个残酷的事实是:大多数 Web 应用并不需要 2,000 个 npm 模块。它们只需要读取数据库、渲染 HTML、处理表单提交,或许再提供一个 JSON API。仅此而已。现代 JavaScript 生态系统让人们相信每个项目都需要构建流水线、打包工具、代码检查器、类型检查器和模块图解析器。但现实是,一个结构良好的服务器端渲染应用——你可以看到页面的实际 HTML 结构,并仅在需要的地方注入后端逻辑——通常比由微服务网格支撑的单页应用更简单、更快、更易于维护。使用 AxonASP,你只需编写带有嵌入式服务器端 JavaScript 的纯 HTML。<% %> 分隔符明确标记了后端逻辑的位置。你可以在一个文件中看到整个页面结构。没有隐藏的抽象层,没有魔法。

Bridging Frontend and Backend with G3TEMPLATE

使用 G3TEMPLATE 桥接前端与后端

One of the hidden gems in the AxonASP ecosystem is the G3TEMPLATE library — a high-performance template rendering engine powered by Go’s html/template underneath. Here’s why it matters for teams: The Designer-Developer Gap. If you’ve ever worked on a project where a frontend designer hands off HTML to a backend developer, you know the pain. The designer builds a beautiful page. The developer cuts it apart into templates, sprinkles in logic, and suddenly the design breaks because someone closed a <div> in the wrong partial. G3TEMPLATE solves this by keeping your template files pure HTML with Go-style template syntax. The designer can open the template file directly in any browser and see exactly what the page will look like. The backend developer binds data through a clean Render(path, data) API. No stepping on each other’s toes. No broken layouts. AxonASP 生态系统中的隐藏瑰宝之一是 G3TEMPLATE 库——一个由 Go 语言 html/template 驱动的高性能模板渲染引擎。这对团队至关重要的原因是:它解决了设计师与开发者之间的鸿沟。如果你曾参与过前端设计师将 HTML 交给后端开发者的项目,你就会明白其中的痛苦。设计师构建了一个漂亮的页面,开发者将其切分成模板并加入逻辑,结果因为某人在错误的片段中闭合了 <div> 标签,导致设计崩溃。G3TEMPLATE 通过保持模板文件为纯 HTML 并使用 Go 风格的模板语法解决了这个问题。设计师可以直接在任何浏览器中打开模板文件,准确查看页面的外观。后端开发者通过简洁的 Render(path, data) API 绑定数据。互不干扰,布局也不会损坏。

(Code examples omitted for brevity) (代码示例略)

Step-by-Step: Building a JavaScript Website on AxonASP

分步指南:在 AxonASP 上构建 JavaScript 网站

Let’s walk through creating an actual website. The entire thing, from scratch. 让我们通过创建一个实际的网站来演示,从零开始。

Step 1: Get AxonASP Running 第一步:运行 AxonASP

Clone the repository and build the server: 克隆仓库并构建服务器:

git clone https://github.com/guimaraeslucas/axonasp.git
cd axonasp
./build.ps1

This gives you three executables: 这将生成三个可执行文件:

  • axonasp-http.exe — standalone HTTP server
  • axonasp-http.exe — 独立 HTTP 服务器
  • axonasp-fastcgi.exe — FastCGI server (for IIS/nginx integration)
  • axonasp-fastcgi.exe — FastCGI 服务器(用于 IIS/nginx 集成)
  • axonasp-cli.exe — CLI runner for batch scripts
  • axonasp-cli.exe — 用于批处理脚本的 CLI 运行器

Start the HTTP server: ./axonasp-http.exe 启动 HTTP 服务器:./axonasp-http.exe By default, it serves files from the www/ directory on http://localhost:8801/. 默认情况下,它会从 www/ 目录提供文件,地址为 http://localhost:8801/

Step 2: Create Your First JavaScript Page 第二步:创建你的第一个 JavaScript 页面

Create www/index.html (yes, AxonASP serves static files too) or www/index.asp for a dynamic page. 创建 www/index.html(没错,AxonASP 也支持静态文件)或 www/index.asp 以实现动态页面。

Step 3: Build a JSON API 第三步:构建 JSON API

One of my favorite use cases — a REST API endpoint with zero dependencies. 我最喜欢的使用场景之一——一个零依赖的 REST API 端点。