Skip to content

Instantly share code, notes, and snippets.

View ZoomZhao's full-sized avatar

ZoomZhao ZoomZhao

  • GuangZhou, China
View GitHub Profile
@ZoomZhao
ZoomZhao / coverage.js
Created February 27, 2018 08:09 — forked from ebidel/coverage.js
CSS/JS code coverage during lifecycle of page load
/**
* @author ebidel@ (Eric Bidelman)
* License Apache-2.0
*
* Shows how to use Puppeeteer's code coverage API to measure CSS/JS coverage across
* different points of time during loading. Great for determining if a lazy loading strategy
* is paying off or working correctly.
*
* Install:
* npm i puppeteer chalk cli-table
> The evolutionary path is:
> monolithic backend-web-framework-based repo -> multi repos with shared infra -> monorepo contains shared infra
>
> The tool support is becoming matured ([Yarn Workspace](https://code.facebook.com/posts/274518539716230), [VSCode's Multi Root Workspaces](https://code.visualstudio.com/updates/v1_16#_preview-multi-root-workspaces))
```
[monorepo]/
├── universal-js-app project for product A/
│ ├── node_modules/
│ ├── common/
@ZoomZhao
ZoomZhao / what-forces-layout.md
Created September 1, 2017 04:02 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
const marky = require('marky')
const render = Vue.prototype._render
const update = Vue.prototype._update
const camelize = str => str && Vue.util.camelize(str)
function getName (vm) {
if (!vm.$parent) return 'root'
return (
camelize(vm.$options.name) ||
camelize(vm.$options._componentTag) ||
@ZoomZhao
ZoomZhao / Middleware.js
Created December 22, 2016 09:49 — forked from unbug/Middleware.js
Powerful Javascript Middleware Pattern Implementation, apply middleweare to any object.
'use strict';
/* eslint-disable consistent-this */
let applyMiddlewareHash = [];
/**
* Composes single-argument functions from right to left. The rightmost
* function can take multiple arguments as it provides the signature for
* the resulting composite function.
*
@ZoomZhao
ZoomZhao / ele.js
Last active December 23, 2016 03:47
// 1
const uls = document.getElementByTagName('ul')
for(u of uls) {
u.classList.add('bar')
}
// 2
document.querySelector('#list > li:nth-child(10)').remove()
@ZoomZhao
ZoomZhao / urlparser.js
Last active August 29, 2015 14:09 — forked from sofish/urlparser.js
var parser = function(url) {
var a = document.createElement('a');
a.href = url;
var search = function(search) {
if(!search) return {};
var ret = {};
search = search.slice(1).split('&');
for(var i = 0, arr; i < search.length; i++) {
@ZoomZhao
ZoomZhao / normalize4mobile
Created July 25, 2014 03:03
mobile normalize
/*! normalize.css v3.0.1 | MIT License | git.io/normalize */
/**
* Remove default margin.
*/
body {
margin: 0;
}

Flux + React:

Views ---> (actions) ----> Dispatcher ---> (registered callback) ---> Stores -------+
Ʌ                                                                                   |
|                                                                                   V
+-- (Controller-Views "change" event handlers) ---- (Stores emit "change" events) --+

NervJS + DarkDOM + Templating or Virtual-DOM (React-like):