Skip to content

Instantly share code, notes, and snippets.

View Kotpes's full-sized avatar

Sergey Dubovik Kotpes

View GitHub Profile
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@dz0ny
dz0ny / intelligentPre-loading.js
Created December 25, 2011 21:19
Prefetch,prerender, preload HTML5 snippet for jQuery
// create an object named "app" which we can define methods on
var app = {
// returns an array of each url to prefetch
searchUniqueWithLimit: function(selector,limit){
// returns an array for selector
var hrefs = $(selector).map(function(index, domElement){
return $(this).attr("href");
});
// returns the array of hrefs without duplicates
return $.unique(hrefs).slice ( 0, limit?limit:5 );