Skip to content

Instantly share code, notes, and snippets.


jakub-g jakub-g

View GitHub Profile
jakub-g / _1_"script async defer" blocks "load"
Last active May 6, 2021
Beware of "script async defer" blocking HTML "load" event
View _1_"script async defer" blocks "load"

Beware of <script async defer> blocking HTML "load" event

2015.10.07 t

On the importance of simulated latency testing, and bulletproofing your page from the third-party JS load failures


jakub-g /
Last active May 3, 2021
Unicode-aware JavaScript regex cheat sheet

Unicode-aware JavaScript regex (Unicode property escapes /\p{..}\P{..}/u) cheat sheet

Browser support MDN

jakub-g /
Last active Apr 30, 2021
Will it double-fetch? Browser behavior with `module` / `nomodule` scripts
jakub-g /
Last active Apr 28, 2021
Mapping Safari releases to Safari TP versions
jakub-g /
Last active Apr 23, 2021
async scripts, defer scripts, module scripts: explainer, comparison, and gotchas

<script> async, defer, async defer, module, nomodule, src, inline - the cheat sheet

With the addition of ES modules, there's now no fewer than 24 ways to load your JS code: (inline|not inline) x (defer|no defer) x (async|no async) x (type=text/javascript | type=module | nomodule) -- and each of them is subtly different.

This document is a comparison of various ways the <script> tags in HTML are processed depending on the attributes set.

If you ever wondered when to use inline <script async type="module"> and when <script nomodule defer src="...">, you're in the good place!

Note that this article is about <script>s inserted in the HTML; the behavior of <script>s inserted at runtime is slightly different - see Deep dive into the murky waters of script loading by Jake Archibald (2013)

jakub-g /
Last active Mar 24, 2021
WebPageTest wishlist 2021

0. Filmstrip page

  • There's no link back to waterfall page
  • Custom end time URL param is not validated. I can put -e:99 and will have 99s worth of filmstrip images (while the test was shorter than that)

1. Re-run the test equivalent which allows changing config

Sometimes I have very elaborate test config which I want to reuse, but slightly change one thing (e.g. add one param to URL). I can easily re-run the test with exact same config, but it's not easy to slightly change config and re-run. You need to re-create the config from scratch by checking multiple checkboxes, and hoping you come up with same exact set of params as before

jakub-g /
Last active Mar 22, 2021

Test query

({a: window.PerformanceObserver.supportedEntryTypes, b: window.PerformancePaintTiming, c: navigator.userAgent})


A TP blog says shipped in TP75 which would mean 12.1 stable but I tested in 12.1 and it's not true. It returns undefined. So I asssume 13.0 (I don't have 13.0 to test).

jakub-g / cleanEmptyFoldersRecursively.js
Created Apr 3, 2015
nodejs: remove empty directories recursively
View cleanEmptyFoldersRecursively.js
function cleanEmptyFoldersRecursively(folder) {
var fs = require('fs');
var path = require('path');
var isDir = fs.statSync(folder).isDirectory();
if (!isDir) {
var files = fs.readdirSync(folder);
jakub-g /
Last active Mar 11, 2021
preact-redux: where can `props` come from
import { compose } from 'redux'
import { connect } from 'react-redux'


compose(func1, func2, func3, func4) === func1(func2(func3(func4))))
jakub-g /
Last active Mar 2, 2021
Configure popular tools to work with ES modules

Things to do before you start using ES modules and put "type": "module" in package.json

The correct behavior of all tools is to assume that .js files are in ES modules format. Hence you must convert existing .js files (including config files) to ESM format, or rename them to .cjs if you want to keep them intact.

eslint, prettier

You should rename .eslintrc.js/.prettierrc.js to .cjs extension, or make them a valid JSON with .json extension

doc: eslint prettier