Skip to content

Instantly share code, notes, and snippets.

View ymatuhin's full-sized avatar
🐈
ᓚᘏᗢ

Yury Matuhin ymatuhin

🐈
ᓚᘏᗢ
View GitHub Profile
// modules.js
const Modules = (function() {
const config = { base: '' }
const modulesPromises = {}
function loadModule(url) {
if (modulesPromises[url]) return modulesPromises[url]
return modulesPromises[url] = new Promise((res, rej) => {
ajaxGET(config.base + url, (moduleText) => {
var loadFile = (function () {
var links = document.getElementsByTagName('link');
var scripts = document.getElementsByTagName('script');
var head = document.getElementsByTagName('head')[0];
var need = {
css: true,
js: true
}
@ymatuhin
ymatuhin / checkWebpSupport.js
Last active May 8, 2021 13:20
Check WebP Support in browser
function checkSupport(fn) {
var html = document.documentElement,
WebP = new Image();
WebP.onload = WebP.onerror = function() {
isSupported = (WebP.height === 2);
if (isSupported) {
if (html.className.indexOf('no-webp') >= 0)
html.className = html.className.replace(/\bno-webp\b/, 'webp');
@ymatuhin
ymatuhin / new-clearfix.css
Created July 29, 2015 09:52
New clearfix css from css-tricks
/* метод Ильи Стрельцына */
.table {
padding: 0 10px;
background: #E76D13;
position: relative;
/* display: table */
-height: 1%; /*IE6*/
*zoom: 1; /*IE6-7*/
display: table;
@ymatuhin
ymatuhin / clearfix.css
Created July 29, 2015 08:33
Clearfix css class with ie > 7 support
.clearfix:after {
content: "";
display: table;
clear: both;
}
.transparent {
filter: alpha(opacity=50);
-moz-opacity: 0.5;
-khtml-opacity: 0.5;
opacity: 0.5;
}