Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

pjs

> 编程语言
Open source

Classes for javascript that don't suck.

196 stars0 likes1 views
WebsiteGitHub

About

Classes for javascript that don't suck.

P.js

P.js is a lightweight layer over javascript's built-in inheritance system that keeps all the good stuff and hides all the crap.

just show me some code already

Okay.

…

how is pjs different from X

Most class systems for JS let you define classes by passing an object. P.js lets you pass a function instead, which allows you to closure private methods and macros. It's also <0.4kb minified (make report: 467).

why doesn't pjs suck?

Unlike some other frameworks out there, Pjs doesn't do any of this:

  • interfaces, abstract static factory factories, and other bloat
  • use Object.create (it even works in IE < 8!)
  • break instanceof
  • hack functions onto this at runtime
  • rely on magical object keys which don't minify (the only special name is init)

what can i do with pjs?

  • inheritable constructors (via the optional init method)
  • closure-based "private" methods (see below)
  • easily call super on public methods without any dirty hacks
  • instantiate your objects without calling the constructor (absolutely necessary for inheritance)
  • construct objects with variable arguments

how do i use pjs?

You can call P in a few different ways:

…

how do i use pjs in node.js?

Assuming you have it installed (via npm install pjs), you can import it with

javascript
var P = require('pjs').P;

and go about your business.

what is all this Makefile stuff about

It's super useful! In addition to make, Pjs uses some build tools written on Node. With the Node Package Manager that comes with recent versions of it, just run

bash
npm install

from the root directory of the repo and make will start working.

Here are the things you can build:

  • make minify generates build/p.min.js

  • make commonjs generates build/p.commonjs.js, which is the same but has exports.P = P at the end

  • make amd generates build/p.amd.js, which is the same but has define(P) at the end

  • make test runs the test suite using the commonjs version. Requires mocha.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言