Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

153
Visualizações
Is there any reason why a user would not be able to load scripts if they are not inside a scripts file?

The problem

I am facing a rather weird issue where a windows 10 user is not able to load scripts if they are in script tags inside of a template file (.html). However scripts are loading fine if they are added into a script file (.js).

The problem is that I am unable to hard code everything into the script files because some values are dynamically generated. Here's a very simple example:

Ex:


   $.ajax({
      url: "{% url 'some-namespace' %}",
      type: "POST",
      data: data,
    ...

If I were to change a url pattern, then I can just do so directly in the Django urls.py file, and not have to update all of the scripts.

How do I know this?

When the user told me he got Uncaught ReferenceError: discardDraft is not defined, then I realized that his computer was not loading scripts inside of templates. I tested this by first adding a basic alert in the template file, and nothing appeared. I then tried adding another alert inside of the scripts file, and voila it works.

So I am extremely puzzled and honestly have no clue how to figure out a solution to this.

Other issues this user faced:

make-corrections.js:96 Uncaught ReferenceError: discardDraft is not defined
    at HTMLButtonElement.<anonymous> (make-corrections.js:96)
    at HTMLButtonElement.dispatch (VM201 jquery-3.5.1.min.js:2)
    at HTMLButtonElement.v.handle (VM201 jquery-3.5.1.min.js:2)
    at HTMLButtonElement.c (rocket-loader.min.js:1)

I tried disabling rocket-loader and turned dev mode on cloudflare, but no dice.

This issue seems to be affecting just this particular user and no one else. They tried two different browsers (Opera and Chrome), Incognito/Private browsing, and with cache disabled checked. All addons were also disabled.

Any ideas what it could be?

Edit:

template:


<body>

<script type="application/javascript" src="{% static 'js/jquery-3.5.1.min.js' %}"></script>

<script>
   code here
</script>

</body>

Edit2: Do I need to add type="application/javascript" for it to work for this user?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda