Results 1 to 9 of 9

Thread: CSS Minify Problem

  1. #1
    Former lead dev Nick's Avatar
    Join Date
    Jun 2009
    Location
    Kakamigahara, Japan
    Posts
    2,915
    Blog Entries
    88
    Thanks
    519
    Thanked 846 Times in 551 Posts

    Default CSS Minify Problem

    In my CSS file, I have a few rules that look like this:

    Code:
    #journal_posts .post_form input { 
        width: 85%;
        margin-bottom: 0.4em;
    }
    When Hotaru minifies the CSS, it changes

    Code:
    #journal_posts .post_form input
    into

    Code:
    #journal_posts.post_form input
    which changes the meaning of the rule and breaks the css.

    Without hacking JSMin, is there anything we can do in CSS to prevent this?

    Thanks.

  2. #2
    Theme & Plugin Development ties's Avatar
    Join Date
    Feb 2010
    Location
    Enschede, The Netherlands
    Posts
    378
    Blog Entries
    1
    Thanks
    14
    Thanked 133 Times in 58 Posts

    Default

    Ok just to let people help some more:
    the minification (dunno if the word exists but...) is done on line 295 of /libs/IncludeCssJs.php
    PHP Code:
    $sCode .= JSMin::minify(file_get_contents($sFile)); // minify files 
    but i think you need to hack the JSmin, or there must be some sort of escape character
    i think the error lies in the fact that its made for compressing JS so it sees
    Code:
    #journal_posts .post_form input
    as
    Code:
    window .location
    which will result in
    Code:
    window.location
    and respectively
    Code:
    #journal_posts.post_form input
    i think there are two solutions to fix this and that would be:
    1 Hack the JSmin library
    2 Do something like this:
    Code:
    #journal_posts div.post_form input
    Edit: This might also work for every .post_form, but dont know how that will be compressed
    Code:
    #journal_posts *.post_form input
    Last edited by ties; 04-29-2010 at 05:38 PM.
    Up top, down low, to slow! - Documentation
    Theme's Newspaper - Nightlight Plugins Autocomplete 0.3 - Mobile 0.2 - Post Images 0.4 - Votebar 0.1

  3. Thanked by:


  4. #3
    Senior Member louis's Avatar
    Join Date
    Apr 2010
    Location
    Fugetaboutit!
    Posts
    118
    Thanks
    35
    Thanked 44 Times in 28 Posts

    Default Just a suggestion...

    Hey Nick,ties have you tried just adding a comma?
    Code:
    #journal_posts, .post_form input
    I have a CSS file I tweak on my Intranet and see this comma-seperated id and class combo. Just thought I toss that in there.

  5. #4
    Theme & Plugin Development ties's Avatar
    Join Date
    Feb 2010
    Location
    Enschede, The Netherlands
    Posts
    378
    Blog Entries
    1
    Thanks
    14
    Thanked 133 Times in 58 Posts

    Default

    Quote Originally Posted by louis View Post
    Hey Nick,ties have you tried just adding a comma?
    Code:
    #journal_posts, .post_form input
    I have a CSS file I tweak on my Intranet and see this comma-seperated id and class combo. Just thought I toss that in there.
    comma splits it, its like doing this:
    Code:
    #journal_posts {
        bla: blabla;
    }
    .post_form input {
        bla: blabla;
    }
    which will be applied on:
    * -> #journal_posts
    and seperate
    * -> .post_form -> input
    instead of
    * -> #journal_posts -> .post_form -> input

    hopes this explains CSS a little i can make an example if you like.
    Last edited by ties; 04-29-2010 at 07:39 PM.
    Up top, down low, to slow! - Documentation
    Theme's Newspaper - Nightlight Plugins Autocomplete 0.3 - Mobile 0.2 - Post Images 0.4 - Votebar 0.1

  6. #5
    Senior Member louis's Avatar
    Join Date
    Apr 2010
    Location
    Fugetaboutit!
    Posts
    118
    Thanks
    35
    Thanked 44 Times in 28 Posts

    Red face Doh!

    Code:
    #journal_posts {
        bla: blabla;
    }
    .post_form input {
        bla: blabla;
    }
    Ah'a gotcha I see now. You are right ties. I just happen to have it open whe browsing this post and see what they did there. Soory I wasn't much help.

  7. #6
    Theme & Plugin Development ties's Avatar
    Join Date
    Feb 2010
    Location
    Enschede, The Netherlands
    Posts
    378
    Blog Entries
    1
    Thanks
    14
    Thanked 133 Times in 58 Posts

    Default

    no problem, its good to see members contributing in any way even if its not helpfull, sorry it couldnt be smaller
    it helps the community to stay alive
    ah ah ah ah staying alive staying alive
    Up top, down low, to slow! - Documentation
    Theme's Newspaper - Nightlight Plugins Autocomplete 0.3 - Mobile 0.2 - Post Images 0.4 - Votebar 0.1

  8. #7
    Senior Member louis's Avatar
    Join Date
    Apr 2010
    Location
    Fugetaboutit!
    Posts
    118
    Thanks
    35
    Thanked 44 Times in 28 Posts

    Thumbs up BeeGee's Gotta love'em

    I do have a bookmark on my work PC To this CSS Tricks site maybe this may provide a tip or an alternative. Can't hurt...

  9. #8
    Former lead dev Nick's Avatar
    Join Date
    Jun 2009
    Location
    Kakamigahara, Japan
    Posts
    2,915
    Blog Entries
    88
    Thanks
    519
    Thanked 846 Times in 551 Posts

    Default

    Thanks very much for the help chaps!

    I fixed it with ties suggestion to add a div before the dot:

    Quote Originally Posted by ties View Post
    2 Do something like this:
    Code:
    #journal_posts div.post_form input
    Good thinking!

    I wonder how many other plugins we have that suffer from the same minification problem... hmmm.... keep your eyes peeled!

  10. #9
    Member
    Join Date
    Jan 2010
    Posts
    37
    Thanks
    41
    Thanked 20 Times in 7 Posts

    Default

    This is actually quite interesting. Would #journal > .post_form work? That would of course target any element that's a child of #journal

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Charset Problem
    By Tony in forum How-To and Troubleshooting
    Replies: 8
    Last Post: 01-27-2011, 06:37 AM
  2. Minify Javascript and CSS
    By williamd in forum How-To and Troubleshooting
    Replies: 1
    Last Post: 02-22-2010, 02:50 AM
  3. I have a problem with SWCMS...
    By leipeic in forum Other
    Replies: 2
    Last Post: 01-02-2010, 02:47 AM
  4. Apostrophes problem
    By nothingman in forum How-To and Troubleshooting
    Replies: 3
    Last Post: 10-31-2009, 09:12 AM
  5. Some problem chars with this »
    By carlo75 in forum How-To and Troubleshooting
    Replies: 1
    Last Post: 10-23-2009, 12:04 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •