Skip to content

Instantly share code, notes, and snippets.

View sebarmeli's full-sized avatar

Sebastiano Armeli sebarmeli

View GitHub Profile
@sebarmeli
sebarmeli / lazy-load-scripts-yepnope
Created October 16, 2012 13:40
Lazy-loading Script using yepnope.js
function loadWhenVisible(domElement, script, callback) {
var rect = domElement.getBoundingClientRect();
if (rect.top >= 0 && rect.left >= 0 &&
rect.bottom <= window.innerHeight &&
rect.right <= window.innerWidth) {
yepnope.injectJs(script, function(){
if (callback) { callback(); }
});
@sebarmeli
sebarmeli / delete_js
Created March 14, 2012 12:09
Delete in JS
(function(){
var a = 5;
delete a; // false
console.log(a); //prints 5
var obj = {
prop1 : "name1"
}
@sebarmeli
sebarmeli / Url query string manipulation
Created November 24, 2010 12:03
Parsing the query string given a parameter. Eg. given http://www.domain.com.au?aaa=vvv SA.URL().getQueryValue("aaa") returns "vvv"
/*
* @author Sebastiano Armeli-Battana (@sebarmeli)
* @version 0.2
*/
/*globals window, SA */
if (!window.SA) {window.SA = {}; }
SA.URL = (function() {
var qstring = window.location.search;
return {
getQueryValue : function(param) {