> What i understand from Brandon and Jörn, thank you for
> the quick reaction, is that it's better to have something like
>
> $(function(){
> $('head').append('<link rel="stylesheet" href="jquery.css"
>type="text/css">');
> });
>
> Than using css styles in the plugins. I understand how you
> could have performance issues with inline styles. So the best
> way to style plugin elements is to use classes and ids as
> much as possible.
When I am writing plugins, I use jQuery for style properties of things that
*must* be there for the plugin to work properly. For example, I might have
an element that has to be position:absolute, but also can be visually styled
by the user for things like color or width. In that case I have the
.css({position:absolute}) wired into the plugin but the user can style the
remainder of the CSS properties by id or class. That way it will kinda-sorta
work even if the user forgets to put in css rules for it.
I do think it is better to use css for properties that are already supported
by css. For example, if you are writing a plugin that needs to know the
minimum width of an element, it is better to use .css("min-width") than to
pass that information to the plugin using options. Even IE6, which doesn't
honor min-width, will give you the value specified for min-width in a css
rule.
The main drawbacks to external stylesheets are complexity and Murphy's Law.
If there are two pieces to your plugin, the odds are high that someone will
grab only one piece and then wonder why it doesn't work. Also, in the
example you give it is actually not requesting that stylesheet until
document.ready fires, which is pretty late in the game. There's a chance
that the document will be displayed before that stylesheet has been
processed and that could make the document look weird for a second or two.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/