Skip to content

Instantly share code, notes, and snippets.


EJ Mason mxmason

View GitHub Profile
fpapado /
Last active Jun 22, 2021
:focus-visible progressive enhancement mixin

Find the full post on

:focus-visible is a standard way of only showing focus styles for keyboard and focus-based modalities. When using it, however, you must take care to not remove :focus altogether, where :focus-visible is not supported.

With CSS, we can achieve progressive enhancement of :focus to :focus-visible:

/* Styles where only focus is supported */
pizzarob / xhr.js
Created Aug 21, 2016
Helper Functions for Making XHR Requests in JavaScript
View xhr.js
function post(url, data) {
return new Promise((resolve, reject) => {
let xhr = new XMLHttpRequest();'POST', url);
xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
xhr.addEventListener('load', () => {
let { response, status } = xhr;
let res = JSON.parse(response);
if(status >= 200 && status < 400){