Code Monkey home page Code Monkey logo

Comments (12)

jezdez avatar jezdez commented on July 30, 2024

Yeah, seems like a great idea. Don't hesitate to work on this :)

from django-compressor.

jschrewe avatar jschrewe commented on July 30, 2024

I'm currently thinking about writing such a filter. While it seems straight forward to put the mhtml stuff into the compressed css, I would hate to do make the css files bigger then necessary for most browsers. So, is there a way to include a second conditionally loaded css file with compressor?

from django-compressor.

EmilStenstrom avatar EmilStenstrom commented on July 30, 2024

I've thought about this too. I don't think splitting it up into two files is worth it. That means there will be an extra http request in ie, the browser that's already the slowest.

An increase in CSS size isnotthat big of a deal.

----- Reply message -----
From: "jschrewe" [email protected]
Date: Sat, Sep 3, 2011 14:43
Subject: [django_compressor] Data URI:s that work in IE6 and IE7 (#10)
To: [email protected]

I'm currently thinking about writing such a filter. While it seems straight forward to put the mhtml stuff into the compressed css, I would hate to do make the css files bigger then necessary for most browsers. So, is there a way to include a second conditionally loaded css file with compressor?

Reply to this email directly or view it on GitHub:
#10 (comment)

from django-compressor.

jezdez avatar jezdez commented on July 30, 2024

Yeah @EmilStenstrom is correct, it's okay to get bigger CSS files in the end.

from django-compressor.

barkan avatar barkan commented on July 30, 2024

As long as the CSS is gzipped, that should be a neglible bump. If the two strings are identical, the second one should see good compression, right?

from django-compressor.

jschrewe avatar jschrewe commented on July 30, 2024

Yeah, okay, the more I look into this, the more I believe that Microsoft really messed the whole mhtml thing up. You are right that it makes no sense to use two files to save size.

But then again Microsoft released a security update as described in this comment: http://www.phpied.com/the-proper-mhtml-syntax/#comment-78586 Basically mhtml needs to be served as a different file from the css and the mhtml file must have the mimetype message/rfc822.

from django-compressor.

vad avatar vad commented on July 30, 2024

i would be happy just to be able to use data: URI in modern browsers. Is it possible to automatically generate something that returns data: on supported browsers and keep the default url on IE6,7? It can use modernizr CSS classes.

from django-compressor.

jschrewe avatar jschrewe commented on July 30, 2024

Yes it is. See this commit: https://github.com/jschrewe/django_compressor/commit/91d9a364a90bb03f7f718c8edf85c0efcc3f0fcf

I'm hoping to find the time today to write a patch and submit a pull request.

from django-compressor.

vad avatar vad commented on July 30, 2024

@jschrewe: wow! thanks! :)

from django-compressor.

EmilStenstrom avatar EmilStenstrom commented on July 30, 2024

I think a nicer way around this is to use conditional comment to send different parameters to compress depending on if the browser is IE or not. Here's a filter that sends Data URI to everyone except that ones that's loaded with an URL parameter:

from compressor.filters.datauri import CssDataUriFilter

DISABLE_PATTERN = "?disable_data_uris"

class ConditionalCSSDataUriFilter(CssDataUriFilter):
    def input(self, elem=None, **kwargs):
        href = elem["attrs_dict"]["href"]
        if DISABLE_PATTERN in href:
            return self.content
        return super(ConditionalCSSDataUriFilter, self).input(**kwargs)

Called like this from your template:

<!--[if (gte IE 8)|!(IE)]><!-->
    {% compress css %}
        <link rel="stylesheet" href="{{ STATIC_URL }}css/style.css">
    {% endcompress %}">
<!--<![endif]-->
<!--[if (lte IE 7)]>
    {% compress css %}
        <link rel="stylesheet" href="{{ STATIC_URL }}css/style.css?disable_data_uris">
    {% endcompress %}">
<![endif]-->

... and enabled like this in your settings file:

COMPRESS_CSS_FILTERS = [
    ...
    'util.compressor_filters.ConditionalCSSDataUriFilter',
]

from django-compressor.

karyon avatar karyon commented on July 30, 2024

i vote for closing this, it's about IE6 and 7.

from django-compressor.

diox avatar diox commented on July 30, 2024

I agree, and the workaround from #10 (comment) should be sufficient (or at least, be a good start) for people that still need IE6/7 support.

from django-compressor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.