Skip to content

Instantly share code, notes, and snippets.

@neilj
neilj / renderHTML.js
Created Oct 18, 2013
Rendering HTML with styles in a way that doesn't conflict with other styles on the page, without using an iframe for each HTML fragment.
View renderHTML.js
var styleFrame = document.createElement( 'iframe' ),
stylesWaiting = [],
styleFrameIsReady = false;
styleFrame.setAttribute( 'style',
'visibility:hidden;position:absolute;top:0;left:0;width:1px;height:1px;' );
styleFrame.addEventListener( 'load', function () {
var doc = styleFrame.contentDocument,
html, i, l;
@neilj
neilj / window-controller.js
Last active Oct 30, 2019
Cross-tab window controller
View window-controller.js
function WindowController () {
this.id = Math.random();
this.isMaster = false;
this.others = {};
window.addEventListener( 'storage', this, false );
window.addEventListener( 'unload', this, false );
this.broadcast( 'hello' );
@neilj
neilj / gist:1532562
Created Dec 29, 2011
Sugared DOM: Better Than Templates
View gist:1532562
var el = ( function () {
var doc = document;
var directProperties = {
'class': 'className',
className: 'className',
defaultValue: 'defaultValue',
'for': 'htmlFor',
html: 'innerHTML',
@neilj
neilj / 15b436de1f9107f3778aad525e5d0b20.js
Created Dec 3, 2011
Solution to Part 2 of canyoucrackit.co.uk
View 15b436de1f9107f3778aad525e5d0b20.js
//--------------------------------------------------------------------------------------------------
//
// stage 2 of 3
//
// challenge:
// reveal the solution within VM.mem
//
// disclaimer:
// tested in ie 9, firefox 6, chrome 14 and v8 shell (http://code.google.com/apis/v8/build.html),
// other javascript implementations may or may not work.
You can’t perform that action at this time.