Slim.js

基于现代标准的快速和强大的前端微框架。「Fast & Robust Front-End Micro-framework based on modern standards」

Github stars Tracking Chart

你好,Slim.js

声明式 Web 组件

Slim 是一个超快、原生、优雅的 Web 组件 开发库。

Slim.js 是一个闪电般快速的库,用于开发基于现代标准的原生 Web 组件和自定义元素。不涉及黑魔法,没有无用的依赖性。

它使用 ES6+DOM 原生 API 来提升 HTML 元素的超级能力。

它是可扩展的。您可以为 DOM 操作添加您自己的指令(HTML-compilant)。

它是可插拔的。你可以添加插件,在组件的生命周期中的不同钩子中激活。

这是另一个框架吗?

不是,它是一个非常薄的代码层(约 3k),只使用浏览器的原生功能 -- 如 W3C 标准所定义的那样 -- 为你的自定义元素添加类似框架的功能。

以下是你所得到的:

  • 使用模板自动渲染。
  • 单向数据绑定,源于模板。无需声明哪些属性是什么。
  • 它可以扩展:任何人都可以添加自定义插件或指令。
  • 它给人的感觉就像一个框架(以一种好的方式),但没有经典框架的限制。它可以在任何地方工作,你可以选择自己的框架。
  • 它小到 3.4K 字节(gzipped),内置的指令都是可选的!它的核心功能只有一个文件,你可以选择自己的框架。
  • 核心功能只需一个文件,你就可以使用了。
  • 没有依赖性,一切都基于本地浏览器的 API。选择您自己的工具。
  • (可选)包含 ES7/Next 语法的装饰器,通过 Babel。
  • 可与其他组件库的混搭库(如 Polymer)一起使用,开箱即用。

符合标准

  • ES6
  • 网络组件V1
  • 不需要转码或编译

无需设置。它只是工作

将 Slim.js 添加到您的项目中,您就可以开始了。

文档

开发者指南

官网采用 Slim.js 搭建(带源映射)。查看源码,自己看吧。

4+ 版本变更及迁移

  • 包文件支持ES6原生模块--即导入/导出。
  • 对于无模块方式,每个文件都有一个文件名.nomodule.js。
指令是在单独的文件中,以减少核心包的大小。对于使用指令。
import 'slim-js/directives/repeat.js'
import 'slim-js/directives/if.js'
import 'slim-js/directives/switch-case.js'
// Or if you need them all
import 'slim-js/directives/all.js'

对于无模块的方式放在你的 HTML 中:

<script src="slim-js/Slim.nomodule.js"></script>
<script src="slim-js/directives/all.nomodule.js"></script>

或者在您的浏览器中使用 ES6 原生模块。

<script type="module" src="slim-js/Slim.js"></script>
<script type="module" src="slim-js/directives/..."></script>



Main metrics

Overview
Name With Ownerslimjs/slim.js
Primary LanguageCSS
Program languageHTML (Language Count: 5)
PlatformLinux, Mac, Web browsers, Windows
License:MIT License
所有者活动
Created At2016-09-27 07:58:10
Pushed At2023-09-06 15:36:01
Last Commit At2023-09-06 17:36:01
Release Count142
Last Release Namev5.0.10 (Posted on 2021-10-25 17:38:55)
First Release Name1.0 (Posted on )
用户参与
Stargazers Count1k
Watchers Count26
Fork Count63
Commits Count571
Has Issues Enabled
Issues Count68
Issue Open Count5
Pull Requests Count43
Pull Requests Open Count9
Pull Requests Close Count15
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

hello, slim.js

Build Status

Chat on gitter

Hello, slim.js

Declarative Web Components

Slim is an ultra fast, native and elegant library for Web Components development

Slim.js is a lightning fast library for development of native Web Components and Custom Elements based on modern standards. No black magic involved, no useless dependencies.

It uses ES6+DOM native API to boosts up HTML elements with superpowers.

It is extensible: You can add your own directives (HTML-compilant) for DOM manipulation.

It is pluggable: You can add plugins that are activated during different hooks in component's lifecycle.

Is this another framework?

Nope. It's a very thin code layer (~3k) that adds framework-like power to your custom elements, using only the browser's native capabilities — as defined by W3C standards.

Here's what you get:

  • Automatic rendering using templates.
  • One-way data binding, derived from templates. No need to declare which properties are what.
  • It can be extended: anyone can add custom plugins or directives.
  • It feels like a framework (in a good way), but without the limits of a classic framework. It works everywhere, you pick your own framework.
  • It's as small as 3.4 KBytes (gzipped) and the built-in directives are OPTIONAL!
  • Single file for core functionality, and you're good to go.
  • No dependencies, everything is based on native browsers' API. Choose your own tools.
  • (Optional) Decorators for ES7/Next syntax, via Babel included.
  • Works with mixins from other component libraries, such as Polymer, out of the box.

Standards-compliant

  • ES6
  • Web Components V1
  • No transpiling or compilation required

No Setup required. It just works.

  • Add Slim.js to your project and you're good to go!

Documentation

The official website is built with Slim.js (with source maps). Check out the source code, see it for yourself.

Version 4+ Changes and Migration

  • Package files supports ES6 native modules - i.e. import / exports.
  • For no-modules approach, every file has a filename.nomodule.js
  • Directives are in separate files, to reduce core package size. For using directives:
import 'slim-js/directives/repeat.js'
import 'slim-js/directives/if.js'
import 'slim-js/directives/switch-case.js'
// Or if you need them all
import 'slim-js/directives/all.js'
  • For the no-module approach place in your HTML:
<script src="slim-js/Slim.nomodule.js"></script>
<script src="slim-js/directives/all.nomodule.js"></script>

or alternatively use the ES6 native modules in your browser:

<script type="module" src="slim-js/Slim.js"></script>
<script type="module" src="slim-js/directives/..."></script>

Contibutors are welcome.

USE THE PLATFORM

Do you want to be a supporter? Contact eavichay@gmail.com.