Skip to content

Instantly share code, notes, and snippets.

View ryanve's full-sized avatar
📶
stay free

deepskyblue ryanve

📶
stay free
View GitHub Profile
@tkadlec
tkadlec / perf-diagnostics.css
Last active June 8, 2023 17:47
CSS used to highlight potential performance issues
:root {
--violation-color: red; /* used for clear issues */
--warning-color: orange; /* used for potential issues we should look into */
}
/* IMAGES */
/*
* Lazy-Loaded Images Check
* ====
console.log('Starting instagram..');
const fetchData = (url) => {
return fetch(url)
.then(data => data.json())
.then(json => {
if (json) {
return Promise.resolve(json);
} else {
return Promise.reject(Error('json is undefined!'));
const makeRequest = async () => {
const value1 = await promise1()
const value2 = await promise2(value1)
return promise3(value1, value2)
}
const makeRequest = async () => {
const data = await getJSON()
if (data.needsAnotherRequest) {
const moreData = await makeAnotherRequest(data)
console.log(moreData)
return moreData
} else {
console.log(data)
return data
}
@ryanve
ryanve / observer.js
Created February 16, 2017 04:01
Mutation observer example listening to any attribute changes
!function() {
var emitter = {
emit: console.dir.bind(console)
}
function emit(mutation) {
var target = mutation.target
var name = mutation.attributeName
var value = target.getAttribute(name)
@ryanve
ryanve / namespacing.md
Last active February 16, 2017 04:02
Namespacing CSS libraries

Imagine a web application that uses multiple CSS frameworks, libraries, components, etc. Class names are bound to conflict. Imagine two libraries: freeform.css and aid.css

Namespaced by prefixing classes

<a class="freeform-text--bold freeform-display--block aid aid--focusable">example</a>

Namespaced by data attribute

<a data-freeform="text--bold display--block" data-aid="focusable">example</a>
localeIdentifier Description
eu Basque
hr_BA Croatian (Bosnia & Herzegovina)
en_CM English (Cameroon)
en_BI English (Burundi)
rw_RW Kinyarwanda (Rwanda)
ast Asturian
en_SZ English (Swaziland)
he_IL Hebrew (Israel)
ar Arabic
@ffoodd
ffoodd / improved-sr-only.markdown
Last active April 11, 2024 22:55
Improved .sr-only

Improved .sr-only

Theorically bulletproof CSS class for visually hide anything and keep it accessible to ATs.

A Pen by ffoodd on CodePen.

License.

$space-inset-default = 16px 16px 16px 16px;
$space-inset-xs = 4px 4px 4px 4px;
$space-inset-s = 8px 8px 8px 8px;
$space-inset-m = 16px 16px 16px 16px;
$space-inset-l = 32px 32px 32px 32px;
$space-inset-xl = 64px 64px 64px 64px;
$space-stack-default = 0 0 16px 0;
$space-stack-xs = 0 0 4px 0;
$space-stack-s = 0 0 8px 0;
$space-stack-m = 0 0 16px 0;
@wassname
wassname / .eslintrc.js
Last active September 14, 2023 23:57
eslint.recommended (annotated)
/**
* eslint.recommended (annotated)
* ================
* Annotated defaults based on eslint.recommended
*
* @author: wassname
* @license: MIT
* @website https://gist.github.com/wassname/4693303388396c5f074b10865a969b43
* @date 2017-11-13T23:08
* @eslint-version: 4.11.0