Discussion for CSSUtilities

Before you ask specific technical questions, please read or search through the existing comments, and any available documentation, to see if your question has already been answered.

You can also subscribe to this discussion (RSS 2.0)

  1. # RE: CSSUtilities

    Posted by ivo p on 2010-04-05 at 12:16:53 (GMT)

    i need to write back into the stylesheet.

    is that possible as well?
    or is it planned for?

  2. # RE: CSSUtilities

    Posted by brothercake on 2010-04-07 at 04:41:45 (GMT)

    Yeah I did consider it, but I thought I'd wait and see if anyone wanted that kinda stuff.

    So what is it you'd like to do - create stylesheets, add rules to existing stylesheet, modify existing rules?

  3. # RE: CSSUtilities

    Posted by ivo p on 2010-04-07 at 13:46:29 (GMT)

    I needed the tool to alter an existing rule in the sheet.


    color: #000000;

    needs to be changed to
    color: #ff0000;

  4. # RE: CSSUtilities

    Posted by brothercake on 2010-04-08 at 15:37:29 (GMT)

    Okay cool, I'll look into for an update. What I imagine I'll implement is a general "write" module, that gives you various capabilities to create and modify stylesheets.

    Cheers  (thumbs-up)

  5. # RE: CSSUtilities

    Posted by ingig on 2010-04-09 at 11:15:09 (GMT)

    You absolutely saved me by posting this library, and it works great.

    One question, can I specify which stylesheets the library should parse. Where I'm using this library there are lot of extra css files that don't affect the layout off the page, but the library is parsing some 10 css files, when it should only parse 2 files.

    Maybe would could define before the init, something like this
    CSSUtilities.define("stylesheets", '.include');
    so link and style elements with class name include will be included or something like that.

  6. # RE: CSSUtilities

    Posted by brothercake on 2010-04-11 at 16:29:12 (GMT)

    You can filter your queries so that it only returns results from particular stylesheets, but I'm guessing that's not the issue, right? You want to save the time and overhead of parsing those stylesheets at all, when you know you won't need them?

    I'm not sure link or style element class names would be the best way to proceed - it's not common to apply classes to those elements (though of course it couldn't hurt to have that option anyway); but I'm thinking maybe something that most stylesheets already employ, that would make it useful for existing pages - like a regular-expression URL pattern maybe, something like this:

    CSSUtilities.define("stylesheets", "(default|main|global)\.css");

    Would you be able to express the conditions you want with something like that?

  7. # RE: CSSUtilities

    Posted by ingig on 2010-04-14 at 00:17:28 (GMT)

    That sound about right, but how would you include a style element?

    I implemented the class thing by changing the code a little, and it was a lot faster off course since it only needed to parse 2 stylesheet files instead of 10 or so. I altered getStyleSheetNodes() and added

    if (allnodes[i].getAttribute('class') == 'include') {

    I agree with you that class shouldn't be used, it was just my little hack.

  8. # RE: CSSUtilities

    Posted by brothercake on 2010-04-14 at 01:58:35 (GMT)

    Hmm good point, maybe then you should have a choice of attribute name and pattern-match for defining them. So your class option could be ratified something like this:

    CSSUtilties.define("stylesheets", "class=/include/");

    And the URL pattern like this:

    CSSUtilties.define("stylesheets", "href=/(default|main|global)\.css/");

    And so on, with whatever attributes and values you can identify the elements you want with. It would also have to be flexible enough to be able to address stylesheets included with @import statements in other stylesheets; so maybe "url" instead of "href", or some additional syntax for specifying a property of the stylesheet other than an attribute of its owner element.

    Perhaps there should be two definitions, for include and exclude:

    CSSUtilities.define("include", "class=/wanted/");
    CSSUtilities.define("exclude", "class=/unwanted/");

    Not sure. I'll have to give it some more thought, but as a basic idea - yup, that's definitely a winner, thanks  (smile)

  9. # RE: CSSUtilities

    Posted by ingig on 2010-04-14 at 11:28:05 (GMT)

    Yes, it sounds like your are on the right track

This discussion is now closed

Discussions are usually kept open until they start getting spammed, which in practice seems to be about 2-3 weeks  (eek!)

Get the script

BSD License → Terms of use

Additional Credits

(Redundent Selectors API)
© 2009 henrik.lindqvist@llamalab.com



Website gadgets

Bits of site functionality:

Usability widgets

Local network apps

Web-applications for your home or office network:

Game and novelties

Our internal search engine is currently offline, undergoing some configuration changes in preparation for a major site overhaul. In the meantime, you can still search this site using Google Custom Search.

In this area

Main areas

[brothercake] a round peg in a square hole, that still fits