Skip to content

Instantly share code, notes, and snippets.

Alexander Farkas aFarkas

Block or report user

Report or block aFarkas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@aFarkas
aFarkas / sssl.js
Created Apr 22, 2011
simple, small script loader
View sssl.js
/*!
* SSSL: smallest, simpelst script loader
* version: 1.0.1
*
* API:
* Normal usage
* sssl(source [,complete]);
*
* Example:
* sssl('jquery.js', function(){
@aFarkas
aFarkas / asyncready.js
Last active Jan 3, 2016
<script async="">
View asyncready.js
/*
asyncReady('jQuery', function(fn){
console.log('jQuery found', fn)
});
asyncReady('jQuery.ui', function(fn){
console.log('jQuery found', fn)
});
*/
window.asyncReady = (function(){
var readys = {};
@aFarkas
aFarkas / html5shiv-minimal.js
Last active Aug 29, 2015
minimal html5shiv
View html5shiv-minimal.js
(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>' +
View pic.html
<picture>
<!--[if IE 9]><video style="display: none;"><![endif]-->
<source srcset="runner-wide.jpg" media="(min-width: 1000px)" />
<source srcset="runner-narrow.jpg" media="(min-width: 600px)" />
<!--[if IE 9]></video><![endif]-->
View mediaquery.js
(function () {
var
documentElement = document.documentElement,
viewportFontSize, viewportHeight, viewportIsPortrait, viewportMax, viewportMin, viewportWidth;
function getViewportFontSize() {
var
body = documentElement.appendChild(document.createElement('body')),
iframe = document.createElement('iframe'),
iframeDocument;
View readystatebug.js
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script>
var onreadys = function(){
console.log(document.readyState);
console.log(document.body);
View runpicturefill.js
var timer;
var run = function(){
runpictureFill();
if(document.readyState == 'complete'){
clearInterval(timer);
}
};
timer = setInterval(run, 250);
setTimeout(run, document.body ? 9 : 99);
View maxres.html
<img src="logo.png" srcset="logo2x.png 200w, logo3x.png 300w" />
@aFarkas
aFarkas / maxres.html
Last active Aug 29, 2015
add maxdpr option
View maxres.html
<!-- if you have 3dpr choose logo3x.png -->
<img src="logo.png" srcset="logo2x.png 200w, logo3x.png 300w" sizes="100px" />
<!--
if you have 3dpr and sizes computes to 100px choose img2.jpg
but if you have 2dpr and sizes computes to 150px take img3.jpg
-->
<img src="img.jpg" srcset="img2.jpg 200w, img3.jpg 300w" maxdpr="2" sizes="100px" />
View maxres-.html
<!-
2x device and viewport 1000px: 2000.jpg (i.e.: 2dpr res)
3x device and viewport 1000px: 2000.jpg (i.e.: 2dpr res) <- constrained
3x device and viewport 1500px: 3000.jpg (i.e.: 2dpr res) <- constrained
->
<img srcset="500.jpg 500w, 1000.jpg 1000w, 1500.jpg 1500w, 2000.jpg 2000w, 3000jpg 3000w, 4000jpg 4000w" maxdpr="2" sizes="100vw" />
You can’t perform that action at this time.