Using a global javascript variable with the static url value is more simple :
<script language="javascript">var STATIC_URL = "{{ STATIC_URL|escapejs }}";</script>
<script src="{{ STATIC_URL }}js/myfile.js"></script>
Then, you can simply use the static url by calling STATIC_URL in myfile.js :
html = '<img src="'+STATIC_URL+'/icons/flags/tn.gif">';
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…