Skip to content

Instantly share code, notes, and snippets.

View Raynos's full-sized avatar

Jake Verbaten Raynos

View GitHub Profile

Virtual DOM and diffing algorithm

There was a [great article][1] about how react implements it's virtual DOM. There are some really interesting ideas in there but they are deeply buried in the implementation of the React framework.

However, it's possible to implement just the virtual DOM and diff algorithm on it's own as a set of independent modules.

@Raynos
Raynos / starred-gists.md
Created February 27, 2012 00:33
My starred gists
  • [Why you don't need Meteor][20]
  • [Shim status of ES6][1]
  • [unshimmable subset of ES5][2]
  • [Host objects][3]
  • [Why you don't need jQuery][4]
  • [All the DOM recursion you'll ever need][5]
  • [The heart of pd][6]
  • [jQuery library critique][7]
  • [klass][8]
  • [tiny select][9]
(function (modules) {
var getBuild = function (build) {
return function (ignore, module) {
module.exports = build.exports;
};
};
var getModule = function (scope, tree, path) {
var name, dir, exports = {}, module = { exports: exports }, require, build;
path = path.split('/');
name = path.pop();
/*
This is an EXAMPLE gulpfile.js
You'll want to change it to match your project.
Find plugins at https://npmjs.org/browse/keyword/gulpplugin
*/
var gulp = require('gulp');
var uglify = require('gulp-uglify');
gulp.task('scripts', function() {
// Minify and copy all JavaScript (except vendor scripts)
@Raynos
Raynos / x.md
Last active January 28, 2023 05:12
A list of minimal DOM libraries

DOM Libraries, the easy way

  • [by. Select elements][1]
  • [fragment. Turn HTML into DOMFragments][2]
  • [class-list. Cross browser HTML5 classList implementation][3]
  • [dom-walk. Traverse the DOM in tree order][4]
  • [xhr. Minimal cross browser, cross domain XHR][5]
  • [insert. Cross browser DOM4 insertion methods][6]
  • [to-array. Convert nodelists into arrays][7]
  • [hidden. Cross browser HTML5 hidden property][8]
@Raynos
Raynos / select.js
Created December 10, 2011 16:01
tiny select. Selecting has never been so awesome \o/
// Pretty fast - http://jsperf.com/select-vs-natives-vs-jquery
/*
By, shortcuts for getting elements.
*/
var By = {
id: function (id) { return document.getElementById(id) },
tag: function (tag, context) {
return (context || document).getElementsByTagName(tag)
},
"class": function (klass, context) {
var uglifyJS = require('uglify-js');
var glob = require('glob-stream').create;
var watch = require('glob-watcher');
var through = require('through');
var fs = require('fs');
var path = require('path');
// uglify -.- wtf. make stream kind of.
function uglify() {
var stream = through()
var http = require("http")
var console = require("console")
var url = require("url")
var Router = require("routes-router")
var jsonBody = require("body/json")
var sendText = require("send-data")
var Validator = require("validate-form")
var app = Router()
/* MultiRead returns a readable that can be sinked
into multiple writables at the same time
The way this works is that the readable has to opened and
closed manually
*/
function MultiRead(readable) {
var dests = []
var currentlyReading = false
function pipe(source, dest, options) {
if (!options) {
options = {}
}
var close = "close" in options ? Boolean(options.close) : true
pump()
return dest