Skip to content

Instantly share code, notes, and snippets.

View shettypuneeth's full-sized avatar

Puneeth Shetty shettypuneeth

View GitHub Profile
@shettypuneeth
shettypuneeth / async-asset-loader.js
Last active October 27, 2017 05:08
Lazy load JS and CSS assets
var ASSET_TYPE = {
css: 'css',
js: 'js'
};
function loadCss(source) {
return new Promise(function(resolve, reject) {
var link = document.createElement('link');
link.type = "text/css";
link.rel = "stylesheet";
const withLogs = (fn) => (a, b) => {
console.log(a, b);
return fn(a, b);
}
const add = withLogs((a, b) => a + b);