Last active
October 8, 2015 20:08
-
-
Save feeela/a67d03239ec39a232381 to your computer and use it in GitHub Desktop.
Require.js: use app.js?... cache-busting URL parameter for loaded modules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function( libFileName ) { | |
var scripts = document.getElementsByTagName( 'script' ), | |
i, src, parts, len = scripts.length; | |
for( i = 0; i < len; i++ ) { | |
src = scripts[i].src; | |
if( src.indexOf( libFileName ) != -1 ) { | |
parts = src.split( '?' ); | |
if( parts[1] ) { | |
/* set requiresjs config */ | |
requirejs.config( { | |
urlArgs: parts[1] | |
} ); | |
} | |
break; | |
} | |
} | |
})( 'app.js' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This snippet should be inserted right after the
requirejs.config()
block. Set the argument of the immediately invoked function to the filename of the script that has a cache busting URL parameter.