Skip to content

Instantly share code, notes, and snippets.

@feeela
Last active October 8, 2015 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feeela/a67d03239ec39a232381 to your computer and use it in GitHub Desktop.
Save feeela/a67d03239ec39a232381 to your computer and use it in GitHub Desktop.
Require.js: use app.js?... cache-busting URL parameter for loaded modules
(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' );
@feeela
Copy link
Author

feeela commented Oct 8, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment