Menu

How does jStyleParser handles CSS it dons't recognise?

daniels
2014-07-31
2014-08-01
  • daniels

    daniels - 2014-07-31

    I need to use jStyleParser to create a tool that will split the CSS in multiple files based on the IE limitation of 4095 rules. So all i need is to load the CSS count and split it.

    Will I have any issues with jStyleParser as will it drop any CSS from the original files that it doesn't recognise? (I've seen support for some :selectors has just been added to the master, so I assume it's not in the current version) Or it still keeps them?

    Is jStyleParser right tool to do this with? (load css, count and split it, output it)

     
  • Radek Burget

    Radek Burget - 2014-07-31

    jStyleParser should preserve all the syntactically correct CSS definitions. I.e. it should preserve even the unknown pseudo-classes but it will discard most CSS hacks and other garbage.

    I mean for your purpose, some text processing tool would be more suitable (e.g. perl or awk on unix) unless you want to apply additional cleaning on your style sheets.

     
  • daniels

    daniels - 2014-07-31

    I really like jStyleParser as it's really easy and nice to use and I wouldn't trust regular expressions or such.

    Another nice thing that I've noticed was that it also cleans the duplicated rules.

    Could this "CSS hacks and other garbage." that gets discarded have any impact over the CSS as in affect the site, have different css from the input? Or it should be safe.

     
  • Radek Burget

    Radek Burget - 2014-08-01

    Some webdesigners used to include "hacks" - intentional syntactical errors in the stylesheets that are normally ignored by most browsers but they are processed in a specific way by a particular target browser (most frequently older versions of Internet Explorer). The purpose is to force some specific definitions to a specific browser only. In that case, discarding the hacks could influence the rendering in the target browsers. However, in modern webdesign, this is not used too often now.

    I would recommed to check your style sheets by some CSS validator and then test, how jStyleParser parses the potentially problematic parts shown by the validator.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.