Giter Club home page Giter Club logo

asta's Introduction

Asta

SSR resumable framework

Run demo

yarn build
yarn start

Use

input:

import { addCount } from '~action/count.js' // esbuild loader return path in server

// state: will run in server and inject to client
export const loader = async (req) => {
	return {
		count: req.query.count,
	}
}

// view: will run in both client and server, but s() in server h() in client
export default ({ count }) => {
	return (
		<main>
			<button $onclick={addCount}>{count}</button>
		</main>
	)
}

output:

<main><button $onclick="./action/count.js?mod=addCount" data-id="1">0</button></main>

Compiler

Sdom in server, Vdom in client

// jsx input
const view = ({list}) => <div>{list.map(i=><i>{i}</i>)}</div>
// server output
const view = ({list}) => s.openTag('div')+s.expression(list.map(i=>s.openTag('i')+s.text(i)+s.closeTag('i')))+s.closeTag('div')
// client output
const view = ({list}) => h('div',{children:[list.map(i=>h('i',{children:[i]}))]})

核心优化

asta 是一个 ssr 特化的框架,它核心的两个优化

  1. client 端 0 js

asta 第一个优化,首屏幕 html 是有事件的,js 根据交互懒加载,这种概念也被称之为 Resumable,不需要 hydrate, inspird by qwik.js

优化成果是不管业务多么复杂,都可以谷歌评分 100 分

  1. server 端只有 html

asta 第二个优化,就是在 server 端只拼接 html,没有 vdom 的遍历,后续直接将 html 当作结构来使用,inspired by marko.js

两个优化,分别解决了 ssr 世界里的两个瓶颈

asta 是无敌的,毫不夸张

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.