
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socketโs new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
VanJS. A minimalist React-like UI library based on vanilla JavaScript and DOM.
VanJS (abbr. Vanilla JavaScript) is an ultra-lightweight, zero-dependency and unopinionated React-like UI library based on pure vanilla JavaScript and DOM. Programming with VanJS feels a lot like React, check-out the Hello World
code below:
// Reusable components can be just pure vanilla JavaScript functions.
// Here we capitalize the first letter to follow React conventions.
const Hello = () => div(
p("๐Hello"),
ul(
li("๐บ๏ธWorld"),
li(a({href: "https://github.com/alexander-xin/van/"}, "๐๐จVanJS")),
),
)
van.add(document.body, Hello())
VanJS helps you manage state and UI binding as well, just like React:
const Counter = () => {
const [counter, setCounter] = state(0)
return div(
bind(counter, c => div(`Counter: ${c}`)),
button({onclick: () => setCounter(counter.val + 1)}, "Increment"),
button({onclick: () => setCounter(counter.val - 1)}, "Decrement"),
)
}
add(document.body, Counter())
VanJS is a Grab 'n Go JavaScript library, there are no 3rd-party dependencies, no transpiling, no IDE setups. Instead, it helps you focus on the business logic. VanJS enables you to code anywhere, anytime, on any device. (Yes, you can even code with VanJS on your smartphones! ๐๐๐)
Under the hood, VanJS is a very thin layer on top of Vanilla JavaScript and DOM, barely enough to make the DOM manipulation and state binding as ergonomic as (if not more than) React, and delegate most of work to standard browser APIs (which is implemented in native code). As a result, the bundled size of VanJS is under 1kB, which is 100+X times smaller than most popular UI frameworks, here is the size comparison chart:
To get started, paste the line below and you're good to go:
import * as van from "https://alexander-xin.github.io/vanjs/van-0.7.1.min.js"
To code without ES6 modules, you can checkout the bundled version:
<script type="text/javascript" src="https://alexander-xin.github.io/vanjs/van-0.7.1.nomodule.min.js"></script>
Insert the code snippet below and you will get a funnier Hello page (src):
Object.assign(window, tags("button", "div", "pre"))
const sleep = millisec => new Promise(resolve => setTimeout(resolve, millisec))
const Hello = ({sleepInterval}) => {
const [headingSpaces, setHeadingSpaces] = state(100)
const [trailingUnderscores, setTrailingUnderscores] = state(0)
const animate = async () => {
while (headingSpaces.val > 0) {
await sleep(sleepInterval)
setHeadingSpaces(headingSpaces.val - 1)
setTrailingUnderscores(trailingUnderscores.val + 1)
}
}
animate()
return bind([headingSpaces, trailingUnderscores],
(headingSpaces, trailingUnderscores) =>
div(pre(`${" ".repeat(headingSpaces)}๐๐จHello Van!${"_".repeat(trailingUnderscores)}`))
)
}
const containerDom = div({id: "helloContainer"})
add(document.body,
containerDom,
button({onclick: () => add(containerDom, Hello({sleepInterval: 2000}))}, "Hello ๐"),
button({onclick: () => add(containerDom, Hello({sleepInterval: 500}))}, "Hello ๐ข"),
button({onclick: () => add(containerDom, Hello({sleepInterval: 100}))}, "Hello ๐ถโโ๏ธ"),
button({onclick: () => add(containerDom, Hello({sleepInterval: 10}))}, "Hello ๐๏ธ"),
button({onclick: () => add(containerDom, Hello({sleepInterval: 2}))}, "Hello ๐"),
)
If you want to get the most up-to-date version, and don't mind being occassionally broken, you can always import the latest release:
import * as van from "https://alexander-xin.github.io/vanjs/van-latest.min.js"
and the nomodule version:
<script type="text/javascript" src="https://alexander-xin.github.io/vanjs/van-latest.nomodule.min.js"></script>
This folder has all historical archieves, including the pre-minified versions that can be used for debugging.
To find more apps built with VanJS, check out our Code Gallery page.
We have an online HTML to VanJS converter to help you convert HTML snippet into valid VanJS Code.
VanJS puts heavy emphasis on the simplicity of the framework. There are only 4 exported functions in the API and feels a lot like React. Because of that, the walkthrough tutorial is the same as the full API referrence, and can be learned within 1 hour for most developers.
FAQs
VanJS. A minimalist React-like UI library based on vanilla JavaScript and DOM.
We found that van-dom demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.ย It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socketโs new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.