Frontend Development 10 min read

Introducing ofa.js: A Lightweight Front‑End Framework for Easy Component Development

The article presents ofa.js, a new front‑end framework that eliminates the need for Node/npm/webpack workflows, allowing developers to quickly create and package components, use template syntax sugar, achieve seamless state synchronization, and build full web applications with minimal setup.

Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Introducing ofa.js: A Lightweight Front‑End Framework for Easy Component Development

Recently a new front‑end framework called ofa.js has emerged. Unlike traditional workflows that rely on Node, npm, and webpack, ofa.js can be used by simply adding a script tag, enabling developers to build large applications with the same ease as React, Vue, or Angular. Extremely Easy to Get Started If you want to use a component such as Ant Design's Button, you normally need to learn Node.js, npm, and React. With ofa.js you only need basic HTML knowledge. The following example shows how to import ofa.js and use the official punch-logo component: 不加班了 下班给我 迟点下班 周末加班 You can copy the above code into a blank HTML file and run it directly, which demonstrates how ofa.js integrates smoothly with traditional web stacks. One‑Step Component Packaging Packaging a component is equally simple; a single HTML file is enough. Below is an official switch component example: To use it, reference the component with the l-m tag: Rich Template Syntax Sugar ofa.js offers many Vue‑like template syntactic sugars, including text rendering, attribute binding, two‑way binding, event binding, conditional rendering, list rendering, and more. Built‑In State Synchronization Unlike other frameworks, ofa.js provides seamless, “no‑feeling” state synchronization. Data objects are automatically kept in sync without explicit function calls. The following example demonstrates a shared dark‑mode toggle: // is-dark.js const isDark = $.stanz({ value: false }); export default isDark; Simple Form Operations Forms can be bound to a data object using the formData method, which provides automatic two‑way synchronization. Example: sex: man woman Hello World! Data can also be set programmatically, which updates the form instantly: Developing Full Applications ofa.js can be used to build complete web applications that are embedded via the o-app component. A minimal HTML entry looks like this: Application Demo SCSR (Static Client‑Side Rendering) The framework also provides a static client‑side rendering solution that retains the interactivity of CSR while allowing pages to be crawled by search engines. Compact Code Size The current version 4.3.29 of ofa.min.js is only 52 KB (18 KB gzipped), making it very lightweight. Other Notes The library has recently been upgraded to version 4, with a limited set of third‑party plugins that will be expanded over time. The author is preparing a UI library based on ofa.js.

Web DevelopmentFrontend Frameworkstate synchronizationComponent Developmentofa.js
Rare Earth Juejin Tech Community
Written by

Rare Earth Juejin Tech Community

Juejin, a tech community that helps developers grow.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.