Skip to content

Instantly share code, notes, and snippets.

@cyberdev
Forked from james2doyle/jquery.getStylesheet.js
Created December 27, 2020 14:53
Show Gist options
  • Save cyberdev/4760f8d2c6cba2e3397210168104fb80 to your computer and use it in GitHub Desktop.
Save cyberdev/4760f8d2c6cba2e3397210168104fb80 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