Javascript Modules not working on some clients - javascript

I recently started using Javascript modules in my websites, and everything was fine when developing on my desktop. I went to do work on my laptop, but for some reason JS is throwing the following error:
Failed to load module script: Expected a JavaScript module script but
the server responded with a MIME type of "text/plain". Strict MIME
type checking is enforced for module scripts per HTML spec.
Both of my machines are on the latest version of Windows 10 and Brave browser. Google doesn't have anything, and I am out of ideas. My best guess is some weird browser version issue, but I cant find anything about it.

Answer:
This is an issue with the http server I was using. My version of Python's http server on my laptop doesnt support modules. this post fixed my issue.
Also why do I have to wait 2 days to mark this as an answer?

Related

safari loads css/js very slow on client certificate SSL website

I have a website where I use client certificates for accessing the site and it runs with SSL required. It runs on IIS 8.5 on a windows server 2012 R2.
All my css and javascript is minified into 4 seperate files
app.js -> Our own javascript
app.css -> Our own css
vendor.js -> External javascript libraries
vendor.css -> External css libraries
All of these files are minified and placed locally on the server.
The site works very well when using chrome or IE from a computer, but when using safari (only tried safari 5 on PC and latest safari on iphone 6/7) the page can stuck in a "loading" mode. The does not happend every time, and when it does it often helps with clearing the cache in safari and try again.
The website also uses local storage to save some userdata, and a cookie that stores a token for authentication. Not sure if this is useful information, just throwing it out there.
It can connect to the webserver, since we can see the EV+ certificate.
When debugging the phone on a mac, or safari on a PC and looking at the network tab in the developer window I can see that sometimes it takes really long time for the browser to load some of the css and/or javascript files.
Sometimes it appears to be vendor.js, and sometimes app.css, and sometimes the other ones. There seems to be no logic to me, that its always the same files etc.
The site is .NET 4.6 site, running with angularjs, signalr 2.2.1 and html5 in the front.
We have tried
Monotoring IIS Logs and network traffic
Remove sourcemap on css/js to reduce file size
Tried reference signalr/hubs (the generated js file). And also tried copying the content into vendor.js so there is a local version instead
Without any success ATM. I would really appreciate help, feeling stuck on this one.
Many Thanks!
It may be dynamic compression. Are you using Brotli compression on the server?
I suggest a detailed analysis of HTTP Request and Response headers. There may be a discrepancy resulting in this unexpected behaviour. I would follow this up with scouring the Safari bug tracker.
The SSL certificate itself may be the issue, or rather Safari's interpretation of policies.
Hope it helps.

Webview. Is it program error or android issue?

I have an app built around Webview. It has three elements, one a direct link to a website the other two link to internal html files containing java script. The app has been downloaded over 1000 times over the last 2 years without a problem until recently a client reported the internal links threw up "File does not exist or cannot be opened" error.
He reported that the app worked previously on his lenovo device but after a failed upgrade and subsequent factory reset produced the error. Reinstall didn't work.
Is it program error or android issue? Is there a fix?
Yes I came to read that now webview got some authentication issue in loading https pages in latest releases especially when we use onReceivedError() method in it and handle some issue. But I am not 100% sure of it as I havent got this issue. So while using webview properly handle SSl certificate. This issue is occurring only in latest releases. This may fix your issues.

Cross-origin-requests-are-only-supported-in-HTTP - On Accessing Sencha Touch Example

I am new for cross platform mobile app development using HTML frameworks like Sencha. Today, I've downloaded Sencha Touch 2.3.1 and tried to open an index file in the examples folder came with the download package.
Surprisingly I couldn't see anything and my console log said
Cross-origin-requests-are-only-supported-in-HTTP
for bootstrap.json
I have seen the same error for some html files on lungo framework's examples. What could be the reason for this ?
I hope all these files will load correctly if I upload them on a server, but I will be wrapping the js file as package while building the app, so this will not work.
I am aware of the Cross Origin Policy which restricts JS to send request to different origin, but I don't understand why this is happening when I have these files locally. Please help me understand this and explain how to overcome this issue.
when you open the page with file:// protocol, the browser disables requests to other files. so when schena touch tries to load bootstrap.json, your browser throws that error. the solution is to host your site on a local webserver and access it through http://localhost/
I recommend appache server, wamp if you're on windows
Another answer explains

Get JS file via HTTPS from a HTTP page

Okay, so what are the ramifications of getting a JS file via an HTTPS call while on a HTTP page.
I assume it would just be a little bit of extra overhead. Would there be any warnings about this call from any certain browser?
Don't ask why. It's just hypothetical.
There shouldn't be any warnings in any browser. You can try it out this URL - http://www.530geeks.com/mixed-content.html. I tested with ie6 and firefox 3.5, they don't complain.
Its logical too - the host page is being served over http, there is no implied trust with the connection. So there is nothing to warn the user.
This will probably trigger the "Mix of secure and insecure" content alert in Internet Explorer.
Sometimes IE (and maybe other browsers) get nervous and complain about pages having a mix of secure and insecure content. Whether what you're doing would cause that would require a simple test.

Very strange JavaScript error in IE7

I am developing JavaScript chat. I have done the prototype, and it seems to work pretty well. But our client says that it doesn't work. We both use IE7 on PC, and try to run the same JavaScript code. I have no idea about the reason.
On my client's machine there is "object is expected" error. I have thought about security restrictions, and tried to make security level higher in my IE, but in this case the script doesn't run and there is no error messages. I am running the script on the remote server.
Clients machine may be running within a group policy which for security reasons can restrict execution of scripts. Hence the client may need to include your prototype as part of their trusted sites and relax restrictions on trusted sites
Are you able to provide any more details about the specific error? Are you sending the client a zipped up version of the solution or is it hosted somewhere?
From the IEBlog; you could try using the Microsoft Script Debugger (see post)
One thing you may find, especially with IE is the error that is reported is actually caused by a previous error in the code.
Try running your javascript through jslint to ensure that it is well formed.
In Firefox with [firebug], enable strict warnings in the console.
Related SO posts.
debugging-javascript-in-ie7.
debugging-javascript-for-ie6.
Edit::
One thing to look for is comma's after the last element in an array, IE seems to ignore the closing brace } and keep adding following code to the array. Firefox gracefully just assumes that you forgot it.
If you're running the code from localhost and he's running it from a remote server then it could be a timing issue - some script could be running before the page has finished loading that's causing a problem on a slow connection that is hidden on a fast connection.
You can get this error if you try to use an exernal script file that the client's browser can not access.
Example :
<script src="http://localhost/scripts/freelib.js" language=Javascript> </script>
You can access freelib.js on your machine, but running it from any other machine it wouldn't work.
Are you sure all the scripts are being loaded? I've seen that error message before when some or all aren't loaded (maybe they didn't get deployed). Try manually copying the addresses of all the js files from the source and pasting them into the address bar to make sure that the browser can actually access them.
Can you run the page on your client's machine in Firefox? The firefox console should give you a more detailed error message than IE will.

Categories