Top Related Projects
The library for web and native user interfaces.
This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
Deliver web apps with confidence 🚀
Cybernetically enhanced web apps
⚛️ Fast 3kB React alternative with the same modern API. Components & Virtual DOM.
A rugged, minimal framework for composing JavaScript behavior in your markup.
Quick Overview
Marko is a fast and lightweight UI library for building web applications. It combines the simplicity of HTML with the power of JavaScript, allowing developers to create dynamic and interactive user interfaces efficiently. Marko is designed to be performant and easy to learn, making it suitable for both small and large-scale projects.
Pros
- Fast rendering and small bundle size, leading to improved performance
- Easy to learn syntax, combining HTML-like templates with JavaScript
- Built-in compiler for optimized output and server-side rendering support
- Seamless integration with existing Node.js and JavaScript ecosystems
Cons
- Smaller community compared to more popular frameworks like React or Vue
- Limited third-party component libraries and ecosystem
- Learning curve for developers accustomed to other UI frameworks
- Less extensive documentation compared to more established libraries
Code Examples
- Basic component:
class {
onCreate() {
this.state = { count: 0 };
}
increment() {
this.state.count++;
}
}
<div>
<h1>Counter: ${state.count}</h1>
<button on-click('increment')>Increment</button>
</div>
- Conditional rendering:
<if(user.isLoggedIn)>
<h1>Welcome, ${user.name}!</h1>
<else>
<h1>Please log in</h1>
</else>
</if>
- Looping through data:
<ul>
<for|item| of=items>
<li>${item.name}</li>
</for>
</ul>
Getting Started
- Install Marko and its CLI:
npm install marko @marko/serve
- Create a new Marko component (e.g.,
hello.marko
):
<h1>Hello, ${input.name}!</h1>
- Create an entry file (e.g.,
index.js
):
import HelloComponent from './hello.marko';
const hello = HelloComponent.renderSync({ name: 'World' });
hello.appendTo(document.body);
- Run the application:
npx @marko/serve index.js
Competitor Comparisons
The library for web and native user interfaces.
Pros of React
- Larger ecosystem and community support
- More extensive documentation and learning resources
- Wider adoption in industry, leading to better job prospects
Cons of React
- Steeper learning curve, especially for beginners
- Requires additional libraries for routing and state management
- Higher bundle size compared to Marko
Code Comparison
React:
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}
const element = <Welcome name="Sara" />;
Marko:
<h1>Hello, ${input.name}</h1>
<welcome name="Sara"/>
Key Differences
- Marko uses a template-based syntax, while React uses JSX
- Marko has built-in async rendering capabilities
- React relies on a virtual DOM, while Marko uses a compile-time approach
- Marko offers both single-file components and separate files for markup and logic
- React has a more explicit component lifecycle, while Marko handles many optimizations automatically
Performance
- Marko generally offers better out-of-the-box performance
- React requires careful optimization to achieve similar performance levels
- Marko's compiler can generate more efficient code for server-side rendering
Learning Curve
- React has a steeper initial learning curve but offers more flexibility
- Marko's syntax is more intuitive for developers familiar with HTML templates
- React's concepts (like hooks) may take longer to master compared to Marko's straightforward approach
This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
Pros of Vue
- Larger ecosystem and community support
- More comprehensive documentation and learning resources
- Flexible and incrementally adoptable framework
Cons of Vue
- Steeper learning curve for complex applications
- Potentially slower rendering performance for large-scale apps
- Less emphasis on server-side rendering capabilities
Code Comparison
Vue component:
<template>
<div>{{ message }}</div>
</template>
<script>
export default {
data() {
return {
message: 'Hello, Vue!'
}
}
}
</script>
Marko component:
class {
onCreate() {
this.state = { message: 'Hello, Marko!' };
}
}
<div>${state.message}</div>
Vue and Marko are both popular JavaScript frameworks for building user interfaces. Vue offers a more extensive ecosystem and flexibility, making it suitable for various project sizes. However, it may have a steeper learning curve for complex applications. Marko, on the other hand, focuses on simplicity and performance, particularly excelling in server-side rendering. The code comparison demonstrates the different syntax and structure between the two frameworks, with Vue using a template-script separation and Marko utilizing a more compact, single-file approach.
Deliver web apps with confidence 🚀
Pros of Angular
- More comprehensive framework with built-in solutions for routing, forms, and HTTP requests
- Larger ecosystem and community support, with extensive documentation and third-party libraries
- TypeScript-first approach, providing better type checking and tooling support
Cons of Angular
- Steeper learning curve due to its complexity and numerous concepts to grasp
- Heavier bundle size, which can impact initial load times for applications
- More opinionated structure, potentially limiting flexibility in some scenarios
Code Comparison
Angular component:
@Component({
selector: 'app-hello',
template: '<h1>Hello, {{name}}!</h1>'
})
export class HelloComponent {
name: string = 'World';
}
Marko component:
class {
onCreate() {
this.state = { name: 'World' };
}
}
<h1>Hello, ${state.name}!</h1>
Angular and Marko are both powerful tools for building web applications, but they cater to different needs. Angular is a full-featured framework suitable for large-scale applications, while Marko is a lightweight UI library focused on performance and simplicity. The choice between them depends on project requirements, team expertise, and desired application architecture.
Cybernetically enhanced web apps
Pros of Svelte
- Smaller bundle sizes due to compile-time optimization
- Simpler syntax with less boilerplate code
- More active community and ecosystem
Cons of Svelte
- Steeper learning curve for developers familiar with traditional frameworks
- Less mature than Marko, with fewer enterprise-level adoptions
- Limited server-side rendering capabilities compared to Marko
Code Comparison
Svelte component:
<script>
let count = 0;
function increment() {
count += 1;
}
</script>
<button on:click={increment}>
Clicks: {count}
</button>
Marko component:
class {
onCreate() {
this.state = { count: 0 };
}
increment() {
this.state.count++;
}
}
<button on-click('increment')>
Clicks: ${state.count}
</button>
Both Svelte and Marko offer component-based architectures for building user interfaces. Svelte focuses on compile-time optimizations and a simpler syntax, while Marko provides powerful server-side rendering capabilities and a more traditional component structure. Svelte's approach results in smaller bundle sizes and less boilerplate, but Marko's maturity and enterprise adoption make it a strong choice for large-scale applications. The choice between the two depends on specific project requirements and team preferences.
⚛️ Fast 3kB React alternative with the same modern API. Components & Virtual DOM.
Pros of Preact
- Smaller bundle size (3KB gzipped) for lightweight applications
- Closer to vanilla JavaScript, easier learning curve for developers
- Faster rendering and better performance in many scenarios
Cons of Preact
- Less extensive ecosystem and fewer built-in features compared to Marko
- Limited server-side rendering capabilities out of the box
- May require additional libraries for complex state management
Code Comparison
Marko:
class {
onCreate() {
this.state = { count: 0 };
}
increment() {
this.state.count++;
}
}
<button on-click('increment')>
Count: ${state.count}
</button>
Preact:
import { h, Component } from 'preact';
class Counter extends Component {
state = { count: 0 };
increment = () => this.setState({ count: this.state.count + 1 });
render({ }, { count }) {
return <button onClick={this.increment}>Count: {count}</button>;
}
}
Both examples demonstrate a simple counter component, showcasing the syntax differences between Marko and Preact. Marko uses a more declarative approach with its custom syntax, while Preact follows a JavaScript-centric approach similar to React.
A rugged, minimal framework for composing JavaScript behavior in your markup.
Pros of Alpine
- Lightweight and minimal, with a small learning curve
- Easy integration into existing projects without build steps
- Reactive and declarative syntax for simple UI interactions
Cons of Alpine
- Limited functionality for complex applications compared to Marko
- Less performant for large-scale applications
- Lacks server-side rendering capabilities out of the box
Code Comparison
Alpine:
<div x-data="{ open: false }">
<button @click="open = !open">Toggle</button>
<span x-show="open">Content</span>
</div>
Marko:
class {
onCreate() {
this.state = { open: false };
}
toggle() {
this.state.open = !this.state.open;
}
}
<button on-click('toggle')>Toggle</button>
<if(state.open)>
<span>Content</span>
</if>
Alpine focuses on simplicity and ease of use, making it ideal for adding interactivity to existing HTML. It's perfect for small to medium-sized projects that don't require complex state management or server-side rendering.
Marko, on the other hand, offers a more comprehensive solution for building web applications. It provides better performance for large-scale applications, server-side rendering capabilities, and a more structured approach to component development. However, it has a steeper learning curve and requires a build step.
Choose Alpine for quick, lightweight interactivity in existing projects, and Marko for building more complex, performant web applications with server-side rendering needs.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
A declarative, HTML-based language that makes building web apps fun ð¥
Docs â Try Online â Contribute â Get Support
Intro
Marko is HTML reimagined as a language for building dynamic and reactive user interfaces. Almost any valid HTML is valid Marko, and Marko extends HTML for building modern applications more declaratively. Among these extensions are conditionals and lists, state, and components.
Marko supports both single-file components and components across separate files.
Single-file component
The following renders a button and a counter of how many times the button has been pressed:
click-count.marko
class {
onCreate() {
this.state = { count: 0 };
}
increment() {
this.state.count++;
}
}
style {
.count {
color: #09c;
font-size: 3em;
}
.press-me {
padding: 0.5em;
}
}
<output.count>
${state.count}
</output>
<button.press-me on-click('increment')>
Press me!
</button>
Multi-file component
The same component as above, but split into:
index.marko
template filecomponent.js
component JS logic filestyle.css
component styles file
index.marko
<output.count>
${state.count}
</output>
<button.press-me on-click('increment')>
Press me!
</button>
component.js
export default {
onCreate() {
this.state = { count: 0 };
},
increment() {
this.state.count++;
},
};
style.css
.count {
color: #09c;
font-size: 3em;
}
.press-me {
padding: 0.5em;
}
Concise Syntax
Marko also supports a beautifully concise syntax as an alternative to its HTML syntax:
Concise syntax | HTML syntax |
---|---|
|
|
Getting Started
npm install marko
- Read the docs
Community & Support
Ask and answer StackOverflow questions with the |
Come hang out in our Discord chat, ask questions, and discuss project direction |
Tweet to |
Contributors
Marko would not be what it is without all those who have contributed â¨
Get Involved!
- Pull requests are welcome!
- Submit GitHub issues for any feature enhancements, bugs, or documentation problems
- Read the Contribution Tips and Guidelines
- Participants in this project agree to abide by its Code of Conduct
Top Related Projects
The library for web and native user interfaces.
This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
Deliver web apps with confidence 🚀
Cybernetically enhanced web apps
⚛️ Fast 3kB React alternative with the same modern API. Components & Virtual DOM.
A rugged, minimal framework for composing JavaScript behavior in your markup.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot