Skip to content

Instantly share code, notes, and snippets.

View foo123's full-sized avatar

Nikos M. foo123

View GitHub Profile
@foo123
foo123 / jquery.execReady.js
Created September 21, 2016 16:41
modified jquery.execReady.js
/**
* Replace jQuery's $.fn.ready() function with a mod exec
*
* Sites that make heavy use of the $(document).ready function
* are generally incompatable with asynchrounous content. The
* the $.fn.ready function only runs once. This script replaces
* the ready function with a module execution controller that
* let's us register functions and execute all of the functions
* as we need them. This is useful after HTML gets injected on the
* page and we want to rebind functionally to the new content.
@foo123
foo123 / smoothState-wordpress.js
Last active December 5, 2018 19:30
smoothState - wordpress integration scripts
!function( $ ){
"use strict";
// include modified jquery.execReeady.js RIGHT AFTER jquery script, to handle onReady as mod exec
// the approach taken here is this:
// only the absolutely necessary assets (scripts/styles) should be included in ALL pages (e.g jquery, jquery.execReday, smoothState.js, smoothState-wordpress.js)
// all other assets (scripts/styles) per specific page should be included INSIDE the page part handled by smoothState, this script will make sure everything will load and init as transparently as possible
// the smoothState container element is #page and the replaced element is #page > .site.inner which should have a class .page-transition as well
// the transitions are parametrisable through some global settings under window.WPSmoothStateOptions which includes duration, inTransition, outTransition classes
// but one can change that if one wishes, this is quite generic since i use libraries of css-based animations with lots of options, so i find this more generic and parametrisable at wil
@foo123
foo123 / umd-single-module-wrapper.js
Last active February 11, 2024 22:29
UMD JavaScript Single Module pattern (no other dependencies) for Node/CommonJS, AMD/RequireJS, Web Workers and Browser
!function( root, name, factory ) {
"use strict";
//
// export the module, umd-style (no other dependencies)
var isCommonJS = ("object" === typeof(module)) && module.exports,
isAMD = ("function" === typeof(define)) && define.amd, m;
// CommonJS, node, etc..
if ( isCommonJS )
@foo123
foo123 / umd-module-wrapper.js
Last active February 11, 2024 22:27
UMD JavaScript Module pattern with dependencies (bundled-in or external) for Node/CommonJS, AMD/RequireJS, Web Workers and Browser (~2.2kB of extra code minified)
!function ( root, name, deps, factory ) {
"use strict";
//
// export the module umd-style (with deps bundled-in or external)
// Get current filename/path
function getPath( isNode, isWebWorker, isAMD, isBrowser, amdMod )
{
var f;