Requesting Robust code to "force" correct MIME types for .css and .js files

Created on 21 February 2012, over 12 years ago
Updated 5 February 2024, 10 months ago

I have come across an annoying problem.

And I am of two minds on this.

First, I'd like Drupal to work despite problems that some ISPs, because of mis-configurations, cause by serving up .css files (and maybe .js files in the future, should browsers start caring about script MIME types) with MIME types that do not conform to IANA specifications.

On the other hand, I don't like enabling ISPs by covering for their mistakes. If everyone covered for them, there would never be any reason for some of them to figure out what they are doing wrong and correct it.

My view is that if we don't correct for their shortcomings, however, that competing Content Management Systems will, and the ISPs will not change, but people will get frustrated with Drupal instead -- incorrectly blaming us for the problem because our code was not capable of correcting the ISP induced errors "out of the box" -- thinking instead that Drupal itself was bugged. That view, even though incorrect, would persist if people switched from Drupal and the problems they had went away. Many users will not be sophisticated enough, at least while starting to evaluate Drupal, to see this.

What I propose is a paradigm shift, where we do not assume that .css and .js files will be served up with the correct MIME types. Instead, we always serve up our .css and script files as a pair of files. One being the "pure" .css file, and the other being a file with the exact same name except that the extension is .php.css and that file would only be to force the correct MIME header with the following line of code being the first code executed:

header('Content-type: text/css');

Then we would add one include to pull the whole of the .css file in. That would be the primary purpose of the pairing. It may be that someone will see some other use that this could have as well.

Consolidation and compression routines would still go to the "pure" .css files, (or maybe not, if there is reason to go another way with this) and the same paradigm would be used for script files as well.

I addressed this problem for Drupal 7 here:

http://drupal.org/node/1412832

Is this doable? I think it should be, and despite how esoteric this is, I see this as potentially having great value. If we are the first ones to correct for this problem, other CMS packages might look more buggy in comparison, at least to those users who use ISPs that serve up the wrong MIME types.

;'{)

✨ Feature request
Status

Closed: works as designed

Version

9.5

Component
BaseΒ  β†’

Last updated about 8 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States Clearbrook

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024