8

I am using jquery-1.7.2.min.js as my jQuery library. This is a file that I have saved in my Style Library and I am referencing it in my master page.

For some users it is failing and the error they are getting is the following:

Refused to execute script from '..../jquery-1.7.2.min.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

The strange thing is that it was working for them before, but just a couple of days ago it stopped working. And for them it is not working on all the browsers.

The way that I had declared it in master page was like this:

 type="text/javascript" src="/Style Library/jquery-1.7.2.min.js">

Then I changed it to :

 type="application/javascript" src="/Style Library/jquery-1.7.2.min.js">

and now it is:

type="application/x-javascript" src="/Style Library/jquery-1.7.2.min.js">

but to no avail.

I read that 'Setting the MIME type properly on the server' fixed someone's issue. If so then how do we set the MIME type properly on the server?

Much Obliged

  • text/javascript is right, what prompted you to change it? – Eric Alexander Aug 11 '14 at 16:49
  • 1
    Make sure the file is actually published – Robert Lindgren Aug 11 '14 at 17:19
  • failing for 'some users' might also be a permissions issue, make sure everyone has read access to its location (in addition to making sure it's published as Robert Lindgren pointed out!) – John-M Aug 11 '14 at 17:45
  • Earlier i kept a copy of the jQuery file onto Site Assets, I updated my code to refer to Google CDN (<script src="ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>) and the error was solved – Sudhir Kesharwani Aug 24 '15 at 18:54
  • @RobertLindgren Thanks for the tip. That was the issue. – NLV Dec 21 '15 at 20:10
6

To resolve the issue

Based on Roberts suggestion:

I had published the js files at one point. Later I moved some of the js files to different folders. Not realizing they have to be republished. I published them again and now the users can see the js files.

I have also changed the type to text/javascript as promted by PirateEric.

  • I wish I would have seen this post earlier :) – user31823 Jan 20 '17 at 0:57
1

Make sure that your JS files are accessible and published as suggested by Robert. In my case, my JS files were located on an other SharePoint Site where the access was denied for my current user. It was a mistake. So, I changed the location to a local library and the issue was solved!

  • This worked for me. The directory in which my JS files were in wasn't accessible to me. I am using Sharepoint 2013 – Pirate X Dec 14 '16 at 9:35
0

I got the same issue and the problem was that the file is not published and haven't gotten a major version. Therefore a user with only read access can't see the file.

I you look at the request for the file, it has the words "access denied" in the response.

The solution is to publish, like Robert said

0

I was facing similar issue for a JS file of custom item display template. A visitor was facing error "Refused to execute script from item_Custom.js because MIME type('text/html') is not executable".

While searching for the answer I stumbled upon this post. Although the question in this post is different, i thought of adding an answer here for anyone facing issue same as me.

I was able to fix this error by again publishing(check out and check in again) the html file for my custom display template.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.