Is it considered good practice to add style to the elements generated by the jQuery plugin in the script itself or in an external stylesheet?
(function($) {
$.myplugin= function(options) {
var options = jQuery.extend({
backgroundColor: '#0066cc',
borderColor: '#003366',
borderWidth: '1px',
fontColor: '#66ccff'
}, options);
var html = '<div id="__plugin">...</div>';
var $plugin= $(html).css({
'color': options.fontColor,
'background-color': options.backgroundColor
'border-color': options.borderColor,
'border-width': options.borderWidth,
'display': 'none'
});
return $plugin.appendTo(document.body);
};
})(jQuery);
Should I make the approach higher and allow the plugin users to pass parameters for the style settings, or should I remove the style elements and use an external style sheet?
My gut reaction tells me that I should use the latter, but I'm curious what standard practice is, or if there is even one?
source
share