Skip to content

Instantly share code, notes, and snippets.

View core.js
// The core app code
var myApp = (function () {
'use strict';
// Create a public methods object
var methods = {};
* Extend the public methods object
pwFoo / broadcast-channel-es6.js
Created Nov 7, 2021 — forked from alexis89x/broadcast-channel-es6.js
Broadcast Channel API polyfill
View broadcast-channel-es6.js
@class BroadcastChannel
A simple BroadcastChannel polyfill that works with all major browsers.
Please refer to the official MDN documentation of the Broadcast Channel API.
@see <a href="">Broadcast Channel API on MDN</a>
@author Alessandro Piana
@version 0.0.6
pwFoo / sw.js
Created Jul 25, 2021 — forked from felquis/sw.js
View sw.js
Copyright 2014 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
pwFoo / PubSub.js
Created Jul 24, 2021 — forked from kjantzer/PubSub.js
PubSub.js - Simple Publish/Subscribe "Class"
View PubSub.js
Lightweight PUBLISH / SUBSCRIBE Class
Original code from: <>
Can be initialized on other Objects to provide pub/sub functionality within that object
ex: = new PubSub();
pwFoo / pubsub.js
Created Jul 24, 2021 — forked from learncodeacademy/pubsub.js
Basic Javascript PubSub Pattern
View pubsub.js
//events - a super-basic Javascript (publish subscribe) pattern
var events = {
events: {},
on: function (eventName, fn) {[eventName] =[eventName] || [];[eventName].push(fn);
off: function(eventName, fn) {
if ([eventName]) {
View hooks-in-a-nutshell.js
// WARNING: There's much more to know/do around hooks, and
// this is just a simplification of how these work.
// shared references, updated
// per each hook invoke
let execution = null;
let current = null;
let context = null;
let args = null;
pwFoo / hook.js
Created Jun 29, 2021 — forked from MaherSaif/hook.js
simple javascript hooks system
View hook.js
Expected Result:
pwFoo / index.html
Created Jun 27, 2021
jQ - Minimal jQuery like framework with event delegation, minimal router and mapping Nodelist items to Node features
View index.html
<!DOCTYPE html>
<html lang="de">
<script src="jQ.js"></script>
<script type="text/javascript">
// create a global instance of jQ
const $ = new jQ()
// Click Event (event delegation, would work with later added elements too!)
$('a[href="/test"]').on('click', (e) => { $('.test').innerHTML = "Clicked!"; e.preventDefault() })
pwFoo /
Created May 15, 2021 — forked from joyrexus/
Vanilla JS equivalents of jQuery methods

Sans jQuery


// jQuery
$(document).ready(function() {
  // code
pwFoo / the-bind-problem.jsx
Created Apr 17, 2021 — forked from Restuta/the-bind-problem.jsx
React, removeEventListener and bind(this) gotcha
View the-bind-problem.jsx
/* Sometimes it's pretty easy to run ito troubles with React ES6 components.
Consider the following code: */
class EventStub extends Component {
componentDidMount() {
window.addEventListener('resize', this.onResize.bind(this)); //notice .bind
componentWillUnmount() {
window.removeEventListener('resize', this.onResize.bind(this));