Skip to content

Instantly share code, notes, and snippets.

@thomasmb
Created October 24, 2013 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thomasmb/7132686 to your computer and use it in GitHub Desktop.
Save thomasmb/7132686 to your computer and use it in GitHub Desktop.
A JS function used to add a stylesheet to the HTML head tag, but only once ( in this cases it uses jQuery )
function add_stylesheet_once( url ){
$head = $('head');
if( $head.find('link[rel="stylesheet"][href="'+url+'"]').length < 1 )
$head.append('<link rel="stylesheet" href="'+ url +'" type="text/css" />');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment