by jasonpriestley · 12y ago · 0 comments
Preprocessors are an inferior solution, limited by the semantics of CSS and leading, by the pervasive use of macros, to needlessly large CSS file sizes.
$("<div>")
.css({width: 100, height: 20, color: 'red'})
.appendTo(container);
Then, since these are just values in normal javascript code, you can refactor as normal. Pull commonly used patterns out into functions (e.g. `importantText(16, "size 16 important text goes here")`).Most styles in the applications I write tend to be inextricably linked to the layout and function of a component (e.g., tabs should be next to each other); in the rare case that a style needs to be customized in different locations or at different times, it becomes a parameter (e.g. `confirmDialog(textStyle, message, onOk, onCancel)`)
No extra tools are needed, beyond jQuery (building up the DOM without jQuery or something like it is awful).
Running JavaScript in your browser automatically from any site that you visit is pretty darn scary when you think about it. You can protect from a whole host of vulnerabilities by disabling it, and then whitelisting only hosts which you trust.