
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@power-js/core
Advanced tools
A powerful JavaScript library for building web components
Fast Rendering
Virtual DOM for detecting deltas and isolating renders.
Minimalistic
Library makes use of only 3 primary functions.
Size
Library is extremely small, just 2.3k (gzipped)
No Dependencies
A standalone library with no dependencies.
Components
Allows you to build components with an encapsulated state.
React-like API
If you know how you use React then you already know how to use PowerJS.
You can use PowerJS with just place the script into your document, but if you prefer html Syntax you should take a look at JSX. There is a Babel plugin which transforms your JSX Syntax into a VDom.
PowerJS is provided as a UMD library to accommodate any loading method.
Included via script
<script src="power.js"></script>
// someFile.js
const { h, Component, render } = power;
// power.h, power.Component, power.render
Included via import
import Power from '@power-js/core';
Included via require
const Power = require('@power-js/core');
There is a repository on github which helps you to get started.
Here is a typical example for a counter component.
JSX:
import Power, { render, Component } from '@power-js/core';
class Counter extends Component {
render(){
return (
<div className="counter">
<p>Counter: {this.props.counter.toString()}</p>
<button click={() => { this.props.counter += 1; }}>+</button>
<button click={() => { this.props.counter -= 1; }}>-</button>
<button click={() => { this.props.counter = 0; }}>Reset</button>
</div>
)
}
}
render(<Counter counter={0} />, document.body);
JS:
import { h, render, Component } from '@power-js/core';
class Counter extends Component {
render() {
return (
h('div', {class: 'counter'},
h('p', null, `Counter: ${this.props.counter.toString()}`),
h('button', {click: () => { this.props.counter += 1; }}, '+'),
h('button', {click: () => { this.props.counter -= 1; }}, '-'),
h('button', {click: () => { this.props.counter = 0; }}, 'Reset')
)
)
}
}
const myCounter = new Counter({ counter: 0 });
render(myCounter, document.body);
Feel free to fork this project and PR!
Dysfunc 💻 👀 | Jan-Markus Langer 💻 👀 |
---|
FAQs
A powerful JavaScript library for building web components.
The npm package @power-js/core receives a total of 1 weekly downloads. As such, @power-js/core popularity was classified as not popular.
We found that @power-js/core demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.