When comparing Aurelia vs Marko Widgets, the Slant community recommends Aurelia for most people. In the question“What are the best JavaScript libraries for building a UI?” Aurelia is ranked 2nd while Marko Widgets is ranked 17th. The most important reason people chose Aurelia is:
Full support for Typescript built in
Specs
Ranked in these QuestionsQuestion Ranking
Pros
Pro Out of the box Typescript support
Full support for Typescript built in
Pro Good binding system
Clear, intuitive and HTML/SVG compliant binding syntax.
Examples:
Default binding => value.bind
One Way binding => value.one-way
Two Way binding => value.two-way
One Time binding => value.one-time
Pro Conventions over configurations
Configured to give you the most common use cases by convention, which means you only need to change the default configuration for edge cases. This means that for normal cases far less boiler plate code has to be written.
Pro Out of the box ES6 support
Aurelia includes native support for ES6 and even comes with a Gulpfile which helps with transpiling ES6 code to ES5.
Pro Allows developers to build their application however they want
Aurelia is extremely unopinionated and was designed to be highly modular. This gives the developer the freedom to develop their application however they want, without forcing them in paradigms or rules predefined by the framework. Likewise, any of the individual components can be swapped out if so desired.
Pro Standards compliant
Aurelia developers always try to keep within existing and emerging Web Standards, making it easier for developers to follow best practices in web development.
Pro Agnostic code
Most of the code you write is Aurelia-agnostic. It's one of the closest libraries that you'll find to basically write plain-old, vanilla Javascript or TypeScript code (classes) and doesn't polluate your HTML/SCSS. That way you can easily test it, switch to another implementation and make it look clean (business oriented). Even the HTML.
Pro Easy to learn
Learning aurelia basically means learning EcmaScript and HTML, since aurelia is designed for standards compliance. Also, aurelia embraces upcoming ES language features by convention, such as ES class decorators for dependency injection, encouraging clean architecture and future-proof code.
Pro Variable binding helps with self-documenting the code
The syntax used to bind variables within the application class is very similar to Javascript itself. You can specify the type of the binding you are using explicitly, which practically self-documents your code and makes it easy to understand whether a value is one-way or two-way binded.
Pro Structure
Aurelia.js consists of modules that can be used as a full framework or separately.
Pro Great documentation
One of the most crucial pieces of any new technology or framework is the documentation. At present even though Aurelia is pre-beta, the documentation is pretty complete. There are code examples missing and whatnot, but for the most part it is concise and makes the main parts of the application easy to understand.
Pro Full commercial support
Aurelia is officially backed by Durandal Inc. and has commercial and enterprise support is available.
Pro Data binding choices with sane defaults
Aurelia defaults to one-way data binding, alining with conventional wisdom. However, there are times when two-way data binding proves useful, such as binding an input widget with a view-model. Aurelia makes two-way data binding available to developers and uses it by convention when appropriate.
Pro Plays well with other frameworks
Aurelia can be used alongside of React and Polymer, since it is designed for interoperability. In practice, this means Aurelia developers can use React components by including an Aurelia custom element:
https://github.com/Vheissu/aurelia-react-example/blob/master/README.md
It also works well with Polymer, since they are both based on the WebComponents standards:
http://aurelia.io/hub.html#/doc/article/aurelia/framework/latest/integrating-with-polymer
Pro Powerful helper CLI available
https://github.com/aurelia/cli
The CLI helps rapid creation of projects with generators, building, deploying and hot reloads. Webpack should be coming soon.
Pro Growing community
The Aurelia community is growing at a great pace. Still doesn’t rival the big players line Angular or React, but the answer to an Aurelia issue is a quick question away on their Discourse.
Pro Provides dependency injection
With dependency injection, you can load in extra javascript and new functionality just when you need it.
This is particularly helpful with testing as you can swap out services for test services.
It also means in single page apps you can load dependencies only as you need them instead of loading them up all up at the start.
Pro Very fast on the server
Using Marko and Marko Widgets to render UI components on the server was shown to be 10x faster than React. A benchmark application was built using both Marko+Marko Widgets and React and the results of rendering a page of 100 search results on the server was measured and compared. Both the Marko Widgets code and the React code used a very similar UI components-based appraoch.
Pro Stateful UI components
Marko Widgets supports stateful UI components. Marko Widgets will automatically rerender a UI component if its internal state changes. A UI component's state is stored in the this.state
property that is a vanilla JavaScript object. All changes to the state should go through the this.setState(name, value)
method (or this.replaceState(newState)
)
Pro Very fast in the browser
Marko Widgets utilizes the morphdom module for updating the DOM and that module was shown to be very competitive with React and virtual-dom.
Pro The real DOM is the source of truth
Marko Widgets does not rely on a virtual DOM abstraction. Instead, the real DOM is always the source of truth. When updating the DOM, the newly rendered DOM is compared with the real DOM.
Pro DOM diffing/patching
Marko Widgets updates the DOM using a DOM diffing/patching algorithm to minimize the number of changes to the DOM when rerendering a UI component due to state changes. The DOM diffing/patching is handled by the independent morphdom library.
Pro Simple JavaScript API for rendering a UI component
The following code illustrates how the render(input)
method exported by a UI component's JavaScript module can be used to render a UI component and insert the resulting HTML into the DOM:
require('./app-hello')
.render({
name: 'John'
})
.appendTo(document.body)
Pro Batched updates
Updates to the DOM are deferred until all state changes have completed for the current tick. That is, changing a widget's state will not cause the UI component's DOM to immediately be updated.
Pro Declarative eventing binding
Marko Widgets offers a simple mechanism for declaratively binding DOM event and custom event listeners to widget handler methods. For example:
<button type="button" w-onClick="handleClick">
Click Me
</button>
And then in the JavaScript:
module.exports = require('marko-widgets').defineComponent({
// ...
handleClick: function(event, el) {
this.doSomething();
}
});
Pro Marko templating engine for the view
Marko is a fast and lightweight, general purpose HTML-based templating engine that compiles templates to CommonJS modules and supports streaming, async rendering and custom tags. Marko is used for rendering UI components and Marko Widgets is used to bind client-side behavior to rendered UI components. Marko can be used independently of Marko Widgets and this makes it suitable in all situations where HTML rendering is needed.
Pro Efficient binding of behavior for UI components rendered on the server.
When utilizing server-side rendering of a UI, Marko Widgets does not require that the UI be rerendered again in the browser just to bind behavior. Instead, extra information is passed down from the server to the client to allow Marko Widgets to efficiently bind widgets to UI components rendered on the server.
Pro Lightweight (~10 KB gzipped)
The runtime for Marko Widgets is extremely small. The runtime is very small and this makes Marko Widgets much simpler and easier to understand and debug. Marko Widgets offloads much of the work and complexity to compile time code so that the work required at runtime is minimal.
Pro Easily reference nested DOM elements and nested widgets
Marko Widgets supports the concept of "scoped" IDs. With scoped IDs, a nested DOM element or nested widget can be given an ID that is unique within the scope of the containing widget. At runtime the actual ID will be the scoped ID prefixed with the ID of the parent widget. A reference nested widget can be obtained using the this.getWidget(scopedId)
method and a reference to a nested DOM element can be obtained using the this.getEl(scopedId)
method.
For example:
<div class="my-app" w-bind>
<button type="button" w-onClick="handleButtonClick">
Click Me
</button>
<alert-overlay visible="false" w-id="alert">
This is a test alert.
</alert-overlay>
<div w-id="clickMessage" style="display: none;">
You clicked the button!
</div>
</div>
And then in the JavaScript code:
module.exports = require('marko-widgets').defineComponent({
// ...
handleButtonClick: function(event, el) {
var alertWidget = this.getWidget('alert');
// Call the `show()` function implemented by the alert widget:
alertWidget.show();
var clickMessageEl = this.getEl('clickMessage');
clickMessageEl.style.display = 'block';
}
});
Pro Efficient event delegation
Marko Widgets supports efficient event delegation to avoid attaching DOM event listeners to each DOM node. Instead, Marko Widgets attaches event listeners on the document.body
event for events that bubble. Events captured at the root are efficiently delegated out to widgets.
Pro UI components can be embedded in a Marko template using a custom tag
The following code illustrates how a UI component can be embedded in a Marko template:
<div>
<app-hello name="Frank"/>
</div>
Cons
Con No big success stories yet
There are no notable big web products build with aurelia yet
Con Needs more support from the community
It would be great to have a lot of plugins made by the community, or video tutorials from experiences when using it. Hopefully in the near term future.
Con Two-way data binding is often considered an anti-pattern
Two-way data-binding means that a HTML element in the view and an Angular model are binded, and when one of them is changed so is the other. One-way data-binding for example does not change the model when the HTML element is changed.
This is a rather controversial subject and many developers consider two-way data binding an anti-pattern and something that is useless in complex applications because it's very easy to create complex situations by using it and being unable to debug them easily or understand what's happening by just looking at the code.
