Skip to content

Instantly share code, notes, and snippets.

View sglazov's full-sized avatar

Sergey Glazov sglazov

View GitHub Profile
@jakub-g
jakub-g / async-defer-module.md
Last active March 24, 2025 07:50
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)

@gaearon
gaearon / modern_js.md
Last active April 14, 2025 19:22
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav
@wilddeer
wilddeer / READMEPLZ.md
Last active January 15, 2024 11:23
Чатра ищет разработчика

Чатра ищет разработчика

Привет!

Мы в Чатре ищем разработчика. Чатра — это современный чат для сайтов. У нас классный продукт, сделанный с любовью и вниманием к деталям, небольшая дружная команда и больше десяти тысяч клиентов в Северной Америке и Европе.

Чат!

Не хватает одного — прекрасного разработчика или разработчицы, желающей присоединиться к нашей команде.

VPN-сервисы

Существует огромное количество VPN-сервисов. Вот два популярных варианта:

  1. https://nordvpn.com/ большие скидки при оплате за 2 и 3 года, возврат денег в течение 30 дней (если зайти на https://nordvpn.com/features/ и пролистать вниз, то появится попап со скидкой 77% — $99 за три года)
  2. https://www.privateinternetaccess.com/ старый, добротный

Таблица сравнения кучи VPN-сервисов https://thatoneprivacysite.net/vpn-comparison-chart/

См. также:

@victor-homyakov
victor-homyakov / detect-unused-css-selectors.js
Last active March 29, 2025 21:33
Detect unused CSS selectors. Show possible CSS duplicates. Monitor realtime CSS usage.
/* eslint-disable no-var,no-console */
// detect unused CSS selectors
(function() {
var parsedRules = parseCssRules();
console.log('Parsed CSS rules:', parsedRules);
detectDuplicateSelectors(parsedRules);
var selectorsToTrack = getSelectorsToTrack(parsedRules);
window.selectorStats = { unused: [], added: [], removed: [] };
console.log('Tracking style usage (inspect window.selectorStats for details)...');
@akella
akella / shaurma.js
Created January 30, 2018 15:45
Plural intl
let items = new Intl.PluralRules('ru-RU');
let result,word;
for(var i = 0;i<25;i++){
if(items.select(i)=='one'){
word = 'шаурма';
}
if(items.select(i)=='few'){
word = 'шаурмы';
}
if(items.select(i)=='many'){
@lostfictions
lostfictions / svg-to-css-clip-path-polygon.js
Created January 2, 2018 02:01
convert an svg to a css clip-path polygon
// why do this? clip-path accepts a `url` reference to an svg element, right?
// the difference is that anything defined as a `basic-shape` can be animated:
// https://developer.mozilla.org/en-US/docs/Web/CSS/clip-path
const input = `121.151,20.761 170.165,55.885 200.872,3.816 231.145,55.884 280.592,20.762 286.854,80.687 346.526,68.666
327.657,126.005 387.276,139.247 346.502,184 395.796,220.302 340.127,244.647 370.611,297.814 309.636,297.457 316.076,358.381
260.303,333.3 241.622,391.529 200.655,345.979 160.121,391.53 141.008,333.302 85.666,358.381 91.673,297.456 31.131,297.813
61.183,244.647 5.947,220.302 54.81,184 14.466,139.248 73.652,126.004 55.216,68.667 114.457,80.688 `
const viewBoxScale = 4
@imevro
imevro / index.html
Last active March 22, 2020 19:22
Minimally working version of SSR (react, react-router, react-helmet, styled-components; implying use of react-scripts without eject)
<!doctype html>
<html lang="ru">
<head>
<meta charset="utf-8">
<meta name="$helmet-placeholder$">
<meta name="$sc-placeholder$">
<style>
! function() {
"use strict";
function e(e) {
(console.error ? console.error : console.log).call(console, e)
}
function t(e) {
return l.innerHTML = '<a href="' + e.replace(/"/g, "&quot;") + '"></a>', l.childNodes[0].getAttribute("href")
}