Skip to content

Instantly share code, notes, and snippets.

@graynorton
graynorton / jank.js
Created November 13, 2018 23:42
A little wrapper function for detecting and displaying jank. Hacked together for a demo, may not be suitable for any legitimate purpose. :-)
const revealJank = (fn) => {
// jank is a master on/off switch from outer scope
if (!jank) return fn();
// scrim is visible when .janking is on body
document.body.classList.add('janking');
setTimeout(() => {
fn();
let lastFrame = window.performance.now();
let goodFrames = 0;
window.it = 'those';
<link rel="import" href="../components/polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
#paper_button {
left: 340px;
top: 250px;
position: absolute;
////////////////////////////////
// Support for Freebase nouns //
////////////////////////////////
var sandbox = this;
jQuery.ajax( {
url: "http://graynorton.com/ubiquity/freebase-noun-support.js",
success: function( script ) {
eval.call( sandbox, script ); // using jQuery.ajax + eval because jQuery.getScript doesn't work in Ubiquity Command sandbox
// A dependency, from Douglas Crockford's "JavaScript: The Good Parts"
if (typeof Object.create !== 'function') {
Object.create = function (o) {
var F = function () {};
F.prototype = o;
return new F();
};
}
// freebaseNounType