Skip to content

Instantly share code, notes, and snippets.

/**
* How to:
* $('div.container').imagesLoaded(function(){console.log('all images loaded in .container');});
* In case you need to support IE8, you need to use HTML5shiv **and** need to modify jQuery the following way:
* https://github.com/jquery/jquery/commit/a9533893b9e5e9a248139f5794c5d6099382cf14
*/
(function($){
'use strict';
$.fn.imagesLoaded = (function(){
var imageLoaded = function (img, cb, delay){
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>
(function(window, factory) {
var lazySizes = factory(window, window.document);
window.lazySizes = lazySizes;
if(typeof module == 'object' && module.exports){
module.exports = lazySizes;
}
}(window, function l(window, document) {
'use strict';
/*jshint eqnull:true */
if(!document.getElementsByClassName){return;}
@aFarkas
aFarkas / index.html
Last active February 17, 2018 14:54
lazysizes requestIdleCallback
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script>
window.lazySizesConfig = window.lazySizesConfig || {};
window.lazySizesConfig.ricTimeout = 0; // test: 0, 50, 100, 300
window.lazySizesConfig.throttleDelay = 40; //test: 0, 40, 100
@aFarkas
aFarkas / sssl.js
Created April 22, 2011 10:18
simple, small script loader
/*!
* SSSL: smallest, simpelst script loader
* version: 1.0.1
*
* API:
* Normal usage
* sssl(source [,complete]);
*
* Example:
* sssl('jquery.js', function(){
@aFarkas
aFarkas / focus-within.js
Last active August 20, 2020 10:49
simple focus-within polyfill
(function(window, document){
'use strict';
var slice = [].slice;
var removeClass = function(elem){
elem.classList.remove('focus-within');
};
var update = (function(){
var running, last;
var action = function(){
var element = document.activeElement;
@aFarkas
aFarkas / html5shiv-minimal.js
Last active April 15, 2021 20:07
minimal html5shiv
(function(createElement){
if(!('hidden' in createElement('a'))){
'abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video'.replace(/\w+/g, function(elem){
createElement(elem);
});
var p = createElement('p');
var parent = document.getElementsByTagName('head')[0] || document.documentElement;
p.innerHTML = 'x<style>' +
@aFarkas
aFarkas / index.html
Last active January 3, 2024 20:18
link[rel="preload"] polyfill
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!-- we use 'preload_' instead of 'preload' to make it testable in chrome -->
<link rel="preload_" onload="console.log(this, 'script');" href="http://code.jquery.com/jquery-1.12.1.js" as="script" />
<link rel="preload_" onload="console.log(this, 'style');" href="https://cdn.jsdelivr.net/bootstrap/3.3.6/css/bootstrap.min.css" as="style" />
<link rel="preload_" onload="console.log(this, 'font');" href="LatoLatin-Regular.woff" as="font" type="font/woff" crossorigin="" />