0

I'm experimenting with getting my "javascript parts" seperated from my html. I followed this post on stack overflow. My goal is to have separate files for each class. I got it working one time. But then I keep getting the first "old" output in the browser console even when its changed. As if it's stuck in there. I tried restarting everything, the computer ect. The other pages in my app that aren't separated works just fine.

I hope someone can help :) Thanks :)

index.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>New page</title>
</head>
<body>
<p>test</p>
<canvas id="canvas" width="1000" height="500"></canvas>

<script type=text/javascript src="{{
    url_for('static', filename='js/main.js') }}"></script>
</body>
</html>

my file main.js is in the static/js folder.

first I wrote main.js:

console.log("new text"); // changed the text

3 Answers3

0

It's likely your browser caching the .js, try opening your page in a incognito/private window (chrome/firefox), clearing your browser cache, or do a hard refresh (Shift + F5).

djnz
  • 2,021
  • 1
  • 13
  • 13
0

You can use Ctrl+F5 or Shift+F5 to reload your current page ignoring cached content.

Your issue is very probably just related to your previous data being cached by the browser in order to enhance performance and reduce the amount of downloaded data.

Pitto
  • 8,229
  • 3
  • 42
  • 51
0

It's cache problem. You can use Flask-Assets extension so then whenever you make a change to your static files it will give it a unique version number. assets.%(version)s.js. Or you can just use Ctrl+r or Ctrl+F5 to purge cache.

LNF
  • 644
  • 8
  • 8