Skip to content

Instantly share code, notes, and snippets.

View gibson042's full-sized avatar

Richard Gibson gibson042

View GitHub Profile
@gibson042
gibson042 / cautiousData.js
Created June 3, 2012 04:50
Cautious conversion of data- attributes to numbers by jQuery.fn.data
// limit .data number parsing to canonical representations
// fixes jQuery tickets #7579; #11297; #10174
(function( $ ) {
var fnData = $.fn.data;
$.fn.data = function( key, value ) {
if ( value === undefined ) {
// parse data attributes on every element (including forms with unfortunately-named controls)
// before the official jQuery.fn.data gets a chance to
@gibson042
gibson042 / comparison.md
Created October 29, 2012 20:37
Sizzle child cache benchmark comparison
  <th class="text-right">
    sizzle.master
selectors
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>QUnit demo</title>
<link rel="stylesheet" type="text/css" href="https://rawgithub.com/gibson042/8592767/raw/9bc1a1a6ec877460420003d3dddf07bdc0304b87/qunit.c621f60e.css">
<script type='text/javascript' src="https://rawgithub.com/gibson042/8592767/raw/6e02a86b147fe8ec4c31db901b31b3ad44c06c34/qunit.c621f60e.js"></script>
<script type='text/javascript'>
QUnit.config.urlConfig.push({
id: "var",
@gibson042
gibson042 / simpleCSS.js
Last active August 29, 2015 14:01
jQuery #15098 remote src
// http://bugs.jquery.com/ticket/15098
(function( window ) {
var getStyles, curCSS;
if ( window.getComputedStyle ) {
getStyles = function( elem ) {
return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
};
curCSS = function( elem, name, computed ) {
var ret;
@gibson042
gibson042 / jquery-attr-expando.js
Last active August 29, 2015 14:06
jQuery PR 1652
/*!
* jQuery JavaScript Library v1.11.2-pre
* http://jquery.com/
*
* Includes Sizzle.js
* http://sizzlejs.com/
*
* Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
* Released under the MIT license
* http://jquery.org/license
@gibson042
gibson042 / 00-notes.md
Last active November 23, 2021 19:11
jQuery.xhr

AJAX Examples

jQuery.xhr will be an asynchronous HTTP request API returning standards-compliant thenables. We have identified two possible approaches:

  • Autosend: control by options parameter; advanced functionality via beforeSend (similar to jQuery.ajax)
  • Chainable: control by options and/or chainable setters; advanced functionality via send: false and a chainable send method

This gist compares the approaches by imagining their use for current jQuery.ajax examples. To better highlight differences, chaining methods will be used instead of options more heavily than is likely in actual practice (assuming that options is available in the "Chainable" solution).

@gibson042
gibson042 / gist:958d433d6aa3f0fc642b
Last active August 29, 2015 14:14
jQuery optimization ideas

jQuery optimization ideas

Size

Simplify pnum

[eE] is overkill while all regular expressions incorporating pnum are theirselves case-insensitive.

jQuery.cssNumber values

@gibson042
gibson042 / README.md
Last active August 29, 2015 14:21
Git and GitHub

Clone me with the URL at right! Make changes!

@gibson042
gibson042 / focus_search.user.js
Last active September 8, 2023 21:52
Focus Search user script
// ==UserScript==
// @name Focus Search
// @namespace https://github.com/gibson042
// @description Responds to <{Command,Ctrl}+/> by attempting to find and focus a page's search box.
// @source https://gist.github.com/gibson042/c9b3406bc54f55726ec4
// @updateURL https://gist.github.com/gibson042/c9b3406bc54f55726ec4/raw/focus_search.user.js
// @downloadURL https://gist.github.com/gibson042/c9b3406bc54f55726ec4/raw/focus_search.user.js
// @version 0.4.0
// @date 2023-09-08
// @author Richard Gibson <@gmail.com>
@gibson042
gibson042 / github-expand-previous.png
Last active May 1, 2019 22:27
GitHub Expand Previous user script
github-expand-previous.png