Skip to content

Instantly share code, notes, and snippets.

View 3stacks's full-sized avatar
🐻
here comes the beast

Luke Boyle 3stacks

🐻
here comes the beast
View GitHub Profile
@3stacks
3stacks / image.css
Created February 10, 2020 00:20
prefers-reduced-data
.image {
background-image: url('original.webp');
}
@media (prefers-reduced-data: reduce) {
.image {
background-image: url('compressed.webp');
}
}
name: Node CI
on: [push]
jobs:
build:
runs-on: ubuntu-18.04
steps:
@3stacks
3stacks / doctors.js
Last active March 5, 2018 10:30 — forked from duyenho/doctors.js
performance - how to avoid bindings in react's render function
// I removed everything bar the component with the binds and hopefully I can just point you in the right direction.
// when we look at doctorFormBlocks.map, there's two issues. One being that you're creating a new function instance with your
// bind every render (which you correctly identified). But two, your map has an arrow function inside it which also results
// a new function instance every render! This would certainly add up.
// Below is the class as you had it before. The way I would do it is to just make your map an instance method on
// the component.
// Before
export default class DoctorsPage extends React.Component {
// For each image in the dataset, output this object:
// { src: "picture-3.jpg", caption: "Lorem Ipsum Dolor 2<br>Ut enim ad minim veniam, quis nostrud exercitation ullamco<br>2017" }
const data = [
{
"title": "Lorem Ipsum Dolor 1",
"description": "Ut enim ad minim veniam, quis nostrud exercitation ullamco.",
"year": "2018",
"images": [
"picture-1.jpg",
@3stacks
3stacks / bundle.webpack.js
Created February 21, 2018 22:38
javascript bundling in 2018 webpack bundle example part 2
(function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.someMaths = someMaths;
var _someFile = __webpack_require__(1);
var _someFile2 = _interopRequireDefault(_someFile);
@3stacks
3stacks / bundle.webpack.js
Created February 21, 2018 22:37
javascript bundling in 2018 webpack bundle example part 1
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
@3stacks
3stacks / bundle.rollup.js
Created February 21, 2018 22:36
javascript bundling in 2018 rollup bundle example
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var multiplier = 10;
function someMaths() {
console.log(multiplier);
console.log(5 * multiplier);
console.log(10 * multiplier);
@3stacks
3stacks / index.js
Created February 21, 2018 22:33
javascript bundling index.js example
import multiplier from './some-file.js';
export function someMaths() {
console.log(multiplier);
console.log(5 * multiplier);
console.log(10 * multiplier);
}
export default 10;
@3stacks
3stacks / webpack.config.js
Last active February 21, 2018 22:34
simple webpack config
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: {
'index.webpack': path.resolve('./src/index.js')
},
output: {
libraryTarget: "umd",
filename: "bundle.webpack.js",