Comments (12)
Yeah, seems like a great idea. Don't hesitate to work on this :)
from django-compressor.
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.
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.
Yeah @EmilStenstrom is correct, it's okay to get bigger CSS files in the end.
from django-compressor.
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.
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.
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.
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.
@jschrewe: wow! thanks! :)
from django-compressor.
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.
i vote for closing this, it's about IE6 and 7.
from django-compressor.
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)
- Replace deprecated imp module with importlib HOT 2
- Django's `get_storage_class` is deprecated in 4.2 (Django 5.1 compat.) HOT 5
- Releasing a new version with Django 4.2 support HOT 3
- No way to specify hashing method for JS files? HOT 1
- Disable offline compression for some scripts HOT 5
- Fix tests with Python 3.9.17, 3.10.12 and 3.11.4 HOT 7
- Dependencies are pinned HOT 1
- Dynamic SCRIPT_NAME and compressed assets HOT 8
- Getting more info when `Error parsing template` happens
- Not compatible with django-components HOT 10
- Issue with losing templates in compress command in version >=3.0.
- optional max_workers for compress command HOT 1
- 'Settings' object has no attribute 'COMPRESSORS' HOT 8
- OSSFuzz Integration HOT 4
- 4.4: compressor.exceptions.OfflineGenerationError raised in tests HOT 4
- Django 5.1 compatibility HOT 1
- Offline compression + inlining bug HOT 3
- Compress command: warn or error about context vars?
- Set compressor_file_storage to CompressorFileStorage HOT 13
- Documentation isn't clear / confusing behavior
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-compressor.