Skip to content

Instantly share code, notes, and snippets.

View bjankord's full-sized avatar
🎵
Chillin'

Brett Jankord bjankord

🎵
Chillin'
View GitHub Profile
@bjankord
bjankord / gist:2710648
Created May 16, 2012 14:12
Srcset with Meta Variables
<head>
<meta name='srcset' var='small' value='320w' />
<meta name='srcset' var='small-2x' value='320w 2x;' />
<meta name='srcset' var='medium' value='600w' />
<meta name='srcset' var='medium-2x' value='600w 2x;' />
<meta name='srcset' var='large' value='1000w' />
</head>
<body>
<img src="images/small/photo.jpg" srcset="images/{srcset}/photo.jpg" alt="The Breakfast Combo">
@bjankord
bjankord / gist:3365812
Created August 16, 2012 02:24
webP feature detect
/*
webP feature detect by jameswestgate
http://queryj.wordpress.com/2012/06/11/detecting-webp-support/
*/
function testWepP() {
var webP = new Image();
webP.src = 'data:image/webp;base64,UklGRjoAAABXRUJQVlA4IC4AAACyAgCdASoCAAIAL' +
'mk0mk0iIiIiIgBoSygABc6WWgAA/veff/0PP8bA//LwYAAA';
webP.onload = webP.onerror = function () {
@bjankord
bjankord / gist:3410238
Created August 21, 2012 01:15
Picture element type attribute example
<picture alt="">
<!-- If browser supports WebP, use image below: -->
<source src="fullsize.webp" type="image/webp">
<!-- Else, use image from which ever source tag currently matches -->
<source src="mobile.jpg">
<source src="medium.jpg" media="min-width: 600px">
<source src="fullsize.jpg" media="min-width: 900px">
<img src="mobile.jpg">
</picture>
@bjankord
bjankord / gist:3429218
Created August 22, 2012 20:49
ReSct.it Script
var ReSRC = function() {
"use strict";
function h(e, t, n) {
var r = new Array;
t == null && (t = document);
n == null && (n = "*");
var i = t.getElementsByTagName(n), s = i.length, o = new RegExp("(^|\\s)" + e + "(\\s|$)"), u, a;
for (u = 0, a = 0; u < s; u++) if (o.test(i[u].className)) {
r[a] = i[u];
a++;
@bjankord
bjankord / gist:3694276
Created September 10, 2012 22:02
Sublime Text Preferences
{
"bold_folder_labels": true,
"color_scheme": "Packages/Color Scheme - Default/github.tmtheme",
"font_face": "Courier New",
"font_size": 10,
"wide_caret": true,
"word_wrap": true,
"tab_size": 2,
"translate_tabs_to_spaces": false
}
@bjankord
bjankord / mq.css
Created October 3, 2012 20:15 — forked from chriscoyier/mq.css
@media only screen and (min-width: 320px) {
/* Small screen, non-retina */
}
@media
only screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( min--moz-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( -o-min-device-pixel-ratio: 2/1) and (min-width: 320px),
@bjankord
bjankord / gist:3983019
Created October 30, 2012 20:59
Cross-Browser Debounce Resize
/*
Tested in:
Chrome - 22 : Works
FF - 16 : Works
IE - 10
IE - 9 : Works
IE - 8 : no alert - check at home
IE - 7 : no alert - ""
IE - 6 : posts alert twice
@bjankord
bjankord / webp-support.js
Created November 6, 2012 22:09
Test for WebP Support
var img = new Image(),
supported = false;
img.src ="data:image/webp;base64,UklGRkYAAABXRUJQVlA4IDoAAABwAgCdASoEAAQAAYcIhYWIhYSIiQIADAzdrBLeABAAAAEAAAEAAPKn5Nn/0v8//Zxn/6H3QAAAAAA=";
img.onload = function() { supported = true; }
img.onerror = function(e) {}
window.onload = function() {
if (supported) {
document.getElementsByTagName('html')[0].className += ' webp';
@bjankord
bjankord / jquery-to-javascript.js
Created November 7, 2012 20:03
jQuery to JavaScript
// jQuery to JavaScript - src: http://sharedfil.es/js-48hIfQE4XK.html
//--------------------------------------------------//
$(document).ready(function() {
// code…
});
document.addEventListener("DOMContentLoaded", function() {
// code…
});
@bjankord
bjankord / gist:4164848
Created November 28, 2012 21:48
Retina/High Resolution Javascript Check
// retina/high resolution check
var retina = function(){
if(window.devicePixelRatio){
if(window.devicePixelRatio >= 2){
return true;
}
} else if(window.matchMedia){
if (window.matchMedia('(min-resolution: 192dpi)').matches){
return true;