• This repository has been archived on 01/Mar/2019
  • Stars
    star
    213
  • Rank 179,499 (Top 4 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created about 9 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Tungsten.js is a modular framework for creating web UIs with high-performance rendering on both server and client.

Tungsten.js

Build Status npm version code coverage

Tungsten.js is a modular framework for creating web UIs with high-performance rendering on both server and client.

wayfair.github.io/tungstenjs/

Status

Tungsten.js is no longer maintained, and the project has been archived. Tungsten served as Wayfair's UI library since 2015, but as we shifted to a more component oriented architecture we realized react.js was a better fit for developing our user interfaces. In 2017, we chose to adopt react.js as our primary web UI framework, and have since migrated many of our features and applications.

What Tungsten.js Provides

  • High-performance virtual DOM updates powered by virtual-dom
  • Use of mustache templates, with HTML parsed by htmlparser2, which render to virtual DOM objects
  • Event system which binds and delegates each event type to the document root
  • Adaptor for Backbone.js views and models

Motivation

Tungsten.js was built as an alternative to existing front-end JavaScript libraries because we needed a library with:

  • Fast, first-class server-side rendering across multiple platforms
  • Fast client-side DOM updates with support back to IE8
  • Modular interfaces to swap out library components as necessary

How Tungsten.js Works

In Tungsten.js, the initial page loaded is rendered with Mustache templates on the server (in, say, C++, PHP, or Go) then rehydrated by Tungsten.js on the client. Subsequent DOM updates are made with those same mustache templates which have been pre-compiled to functions which return virtual DOM objects used by virtual-dom to diff and patch the existing DOM.

An adaptor layer is used to connect with Tungsten.js with a preferred modular client-side framework to handle data and view management. The default adaptor is a thin layer on top of Backbone.js with a childViews hash to define relationships between views and a compiledTemplate property to define the root pre-compiled template function. Other adaptors can also be used with the core library.

Tungsten.js has no dependency on jQuery.

Setup

Install

npm install tungstenjs --save

For the latest, but unstable, version:

npm install git+http://github.com:wayfair/tungstenjs.git#master --save

UMD

The UMD build is the preferred method for including Tungsten.js in a project, and is generally included via require('tungstenjs'). Dependencies are bundled in the build. It exposes underscore and backbone as tungstenjs._ and tungstenjs.Backbone to be used globally if necessary.

To compile templates, use tungsten.templateHelper.compileTemplates({myTemplate: 'Hello {{name}.'}). Ordinarily this is done on the server at build time.

An client-side only example of a Tungsten.js app using the UMD build is available in the examples.

Bundler (e.g., webpack)

Tungsten.js can be built for your application using a module bundler such as webpack. Because Backbone expects jQuery to be present, Tungsten.js includes a jQuery-less shim, src/polyfill/jquery, which is included in the default build.

Requirements

  • Node.js (for builds; not necessary for production runtime)
  • webpack or other CommonJS compatible client-side module loader
  • {{ mustache }} renderer on server (for server-side rendering)

API

The API a developer interacts with when building an API with Tungsten.js is the API of the Backbone adaptor, which provides View, Model, and Collection properties. These are available directly when importing the Tungsten.js build and are used as the base view, model, and collection constructors in the application. As usual with Backbone, custom constructors can extend from each of these.

Getting Started

When building a Tungsten.js app we recommend starting with an app model, app view, and app (mustache) template. These are the entry points for a Tungsten.js applications. A place to bootstrap the app and get everything started is also needed: often this is in the form of an init file:

var AppView = require('./views/app_view');
var AppModel = require('./models/app_model');
var template = require('../templates/app_view.mustache');

module.exports = new AppView({
  el: '#app',
  template: template,
  model: new AppModel(window.data)
});

See the Tungsten.js TodoMVC app for a complete example.

Documentation

Detailed documentation on Tungsten.js features can be found in /docs:

Versioning

master changes regularly and so is unsafe and may break existing APIs. Published releases, however, attempt to follow semver. High level changelog available at CHANGELOG.md.

Credits

Tungsten.js was created by Matt DeGennaro and is maintained by the JavaScript team at Wayfair. Contributions are welcome.

Tungsten.js uses portions of these and other open source libraries:

License

Tungsten.js is distributed with an Apache Version 2.0 license. See LICENSE for details. By contributing to Tungsten.js, you agree that your contributions will be licensed under its Apache Version 2.0 license.

More Repositories

1

brickkit-ios

DEPRECATED - BrickKit For IOS
Swift
603
star
2

panel-layout

Panel Layout is a UI library for Android that allows you to display a floating and resizable panel that can also snap to the edges.
Kotlin
248
star
3

awesome-learning

Awesome Learning - Learn JavaScript and Front-End Fundamentals at your own pace
JavaScript
229
star
4

terrafirma

A static analysis tool for Terraform plans.
Python
45
star
5

todomvrxdatabinding

Android Architecture based on MvRx and Data binding
Kotlin
34
star
6

prelude

Swift
33
star
7

kombucha

API snapshot testing
Swift
24
star
8

jaeger-swift

Jaeger/OpenTracing implementation for Swift
Swift
18
star
9

awesome-learning-exercises

Awesome Learning Exercises - the source code for the Awesome Learning platform.
JavaScript
15
star
10

redux-ledger

⭐ Async Redux Testing Middleware
JavaScript
11
star
11

react-boston

JavaScript
10
star
12

flask_semantic_image_search

A simple and fast image search engine using convolutional neural networks. Quickly spin up a microservice with your own model and/or images using our Docker images.
Python
10
star
13

tesla

Multi threaded, incremental, batch based data replication tool which is built with heterogeneous sources and destinations in mind.
C#
9
star
14

gists

because you can't create gists as an organization
Jupyter Notebook
8
star
15

sp-phpunit

Shell
8
star
16

statsd-plugins

Collection of plugins for statsd
Python
7
star
17

fasttext-keras

Python implementation for the FastText model implementation developed by Facebook.
Cython
6
star
18

eggsnspam

Python
5
star
19

fixing-fixed-headers

JavaScript
4
star
20

useAccessibleBlockLink

A reusable react hook that preserves a components semantic accessibility to create a visual block link. Supports multiple links within the same block.
TypeScript
4
star
21

pure-ftpd-getvirtualdirs

C
3
star
22

nofollow_highlighter

Nofollow link highlighter extension for Google Chrome
JavaScript
2
star
23

drupal-vulnscan

PHP
2
star
24

Graylog2-GroupBy

Provide something similar to a group by functionality for graylog2
PHP
2
star
25

exchange-mailbox-export

PowerShell
1
star
26

memcache

Fork of https://git.php.net/repository/pecl/caching/memcache.git
C
1
star
27

foxdie

Repository cleaning tool for branches and pull requests
Rust
1
star