Skip to content

Instantly share code, notes, and snippets.

write, the codes

Jason Miller developit

write, the codes
Block or report user

Report or block developit

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View *


import lazyLoad from 'lazy-loader';

let mapPromise;
function getMap() {
  return mapPromise || (
    mapPromise = lazyLoad('/chunks/map.js', () => {
View *


There's no way to <link rel=preload> a Web Worker. This fixes that.

npm i -S gist:developit/567dde2346d785b2628224fddbf6783c

<!-- workers are now just a normal script preload: -->
<link rel=preload href=/path/to/worker.js as=script crossorigin>
View *

inline-loader for webpack

Point this loader at an empty file, and it'll let you supply fake contents for that file.

import one from 'inline-loader?filenam=one.js&code=export default 1!./empty.js';

console.log(one)  // 1
View .gitignore
View *gzip-sizes


A tiny CLI tool to print the gzipped sizes of files matching a glob pattern.


gzip-sizes [...pattern] [options]


View *Modern Script

Modern Script Loading

Loading modern code for modern browsers while still supporting older browsers should be possible via module/nomodule:

<script type="module" src="/modern.js"></script>
<script nomodule src="/legacy.js"></script>

... however this results in over-fetching of scripts in Edge and Safari.

developit /
Created Jul 2, 2019
Test a local copy of Next.js against apps

Given a directory structure like the following:

  📂next    <-- your Next.js checkout

Here's how to build your local copy of Next.js. You'll want to do this every time you make a change to Next itself.

View transform-edge-default-params.js
/** Converts destructured parameters with default values to non-shorthand syntax, fixing Edge 16 & 17. */
module.exports = (babel, options = {}) => {
const { types: t } = babel;
const isArrowParent = p => p.parentKey=='params' && p.parentPath && p.parentPath.isArrowFunctionExpression();
return {
name: "transform-edge-default-parameters",
visitor: {
AssignmentPattern(path) {
View worlds-worst-minifier.js
export default code => code.replace(/(?:[\s\t]+\/\*[\s\S]*?\*\/[\s\t]*|\s*(\n)\s*\/\/.*(?:\n\s*\/\/.*)*)/g, '$1')
# scaffold your project
npx preact-cli@rc create default my-app && cd my-app
# upgrade to Preact X
npm i -D preact-cli@rc && npm i preact@next preact-router@next preact-render-to-string@next
npm rm preact-compat
You can’t perform that action at this time.