Sometimes you just want a file to be served directly from your site, not from a CDN.
This patch adds an $alter parameter to file_create_url() that defaults to TRUE.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | dont-alter-js-uris.patch | 2.46 KB | jbrown |
| no_file_url_alter_option.patch | 1.13 KB | jbrown |
Comments
Comment #1
wim leersI think you should just configure the integration with the CDN to *not* serve the file from the CDN. The module should not decide about this, the developer/end user should.
Comment #2
jbrown commentedThere are times when the module that is requesting the URL for a file wants to be sure that the URI it is derived from will not be altered by another module.
For example (as you know), javascript can have same origin policy issues.
The attached patch prevents modules from modifying the URI of javascript files.
It is not appropriate to rely on module settings to work around this issue.
Comment #3
c960657 commentedSame origin policy is not applied when scripts are loaded using
<script src="http://elsewhere.example.com/foo.js">, is it?Comment #4
jbrown commentedAs far as I'm aware it is: https://developer.mozilla.org/En/Same_origin_policy_for_JavaScript
Comment #5
wim leersI understand your concern. It make sense from a usability POV: you don't want to users of your module to ever have to worry about those things.
However, I strongly disagree with your proposal.
I would be fine with "tagging" files to ensure they get served from the same domain (to comply with the same origin policy). But what if I want to aggregate and minify the CSS and then serve it from the local domain? This patch would disallow even that.
In summary: I agree with the concept, I don't agree with the actual implementation. Your implementation works from a usability POV, but it completely prevents performance enhancements and is therefore unacceptable.
Comment #6
wim leers