Skip to content

Instantly share code, notes, and snippets.

@enix-app
Forked from james2doyle/jquery.getStylesheet.js
Created August 20, 2018 15:52
Show Gist options
  • Save enix-app/61d247e6b5250de0334604187eb80172 to your computer and use it in GitHub Desktop.
Save enix-app/61d247e6b5250de0334604187eb80172 to your computer and use it in GitHub Desktop.
An implementation of $.getScript but for stylesheets. Call it $.getStylesheet
(function($) {
$.getStylesheet = function (href) {
var $d = $.Deferred();
var $link = $('<link/>', {
rel: 'stylesheet',
type: 'text/css',
href: href
}).appendTo('head');
$d.resolve($link);
return $d.promise();
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment