Skip to content Skip to sidebar Skip to footer

Javascript Mime Type Warning On Firefox

I am loading the java-script file in Django template: It is loading properly on Chrom

Solution 1:

Remove the type or change it to "text/javascript".

In html5 spec the type is not required unless it is not javascript

Solution 2:

To add onto evilpie's answer, the root cause for me was using the basic py -m http.server for local testing. In order to correctly assign .js files the 'text/javascript' MIME type, I instead use this script from Github user HaiyangXu.

# -*- coding: utf-8 -*-#test on python 3.4 ,python of lower version  has different module organization.import http.server
from http.server import HTTPServer, BaseHTTPRequestHandler
import socketserver

PORT = 8080

Handler = http.server.SimpleHTTPRequestHandler

Handler.extensions_map={
        '.manifest': 'text/cache-manifest',
    '.html': 'text/html',
        '.png': 'image/png',
    '.jpg': 'image/jpg',
    '.svg': 'image/svg+xml',
    '.css': 'text/css',
    '.js':  'application/x-javascript',
    '': 'application/octet-stream', # Default
    }

httpd = socketserver.TCPServer(("", PORT), Handler)

print("serving at port", PORT)
httpd.serve_forever()

Source: https://gist.github.com/HaiyangXu/ec88cbdce3cdbac7b8d5

Solution 3:

Your server is wrongly configured and is serving .js files with a wrong Content-Type header of text/plain.

In the future Firefox might start blocking scripts with incorrect MIME types.

Post a Comment for "Javascript Mime Type Warning On Firefox"