Forums

CSS & images display, JS does not load

I am encountering a very interesting issue with the JS on my web app.

I had my web app working 100% correctly on my antxmod.pythonanywhere.com domain a few days ago. After purchasing a domain name and moving the site over to www.sim-helper.com, the JS for some of the moving elements and the mobile menus does not load.

I have tried to change the static file mapping to no avail.

I dont know what else to try. The js works on a local flask env, and it also worked before i transfered my site to the new domain. Any ideas?

Looks like a http vs https problem. If a page is loaded into a browser using HTTPS, the browser will refuse to load any scripts for it over HTTP, in order to avoid security problems. So if (for example) you have a template that loads up a script using an HTTP URL like this:

<script type="text/javascript" src="http://somecdn.com/something.js"></script>

...and then the template is used to render a page that someone is viewing over an HTTPS URL, the script won't be loaded. In that case, you could fix it by using an HTTPS link for the script:

<script type="text/javascript" src="https://somecdn.com/something.js"></script>

Thanks. It is working correctly now.

hello there, even I am facing same issue, my js with cdn work properly but not the local js files which are added in python anywhere. it worked fine in the localhost but is not working after hosting

What is the url you have a problem with?

2021-05-19 09:32:38,988: Not Found: /static/js/main_javascript.js 2021-05-19 09:32:39,009: Not Found: /static/js/Phone.js

i am getting this error but all my css and images included in static file are working fine..everything was working fine on localhost too but after hosting the website js files are not having problem. but js files with cdn works fine...

<script src="{% static 'js/main_javascript.js' %}" type="text/javascript"></script> <script src="{% static 'js/Phone.js' %}" type="text/javascript"></script>

this is code i have used in my base.html file..to include the js other js like

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous"></script>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>

<script src="https://kit.fontawesome.com/bc6ea75b90.js" crossorigin="anonymous"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.12/js/intlTelInput.js" integrity="sha512-lib7WdJvAnfLLBi5AHdN+wUkcWwpu1fmYzyEHQijZq7WedcwBiwdVNbcML2rAtKvwtOIU7thMGB+O9Kpb9g2Cw==" crossorigin="anonymous"></script>

works fine. i do not know what is going wrong.

Take a look at https://help.pythonanywhere.com/pages/DjangoStaticFiles

My <script> tag does not work http://fr0gs.pythonanywhere.com

Which script tag is that?

The javascript script /script tag

I don't see one of those on http://fr0gs.pythonanywhere.com/.

It started working ¯_(ツ)_/¯ after stack exchange downvotes

I'm not sure if correlation is causation here, but glad you got that working! :-)

It was because: 1. I was giving it a server path. It needed a url path. 2. I forgot to write

type='text/javascript'