I have the following directory structure which follows Django's standard:
/my_site
/my_site
/my_app
/static
/my_app
/js
a.js
b.js
c.js
d.js
I have no problem specifying the static path in the html:
{% load staticfiles %}
<script src="{% static 'my_app/js/a.js' %}"></script>
However, there are some statements in file a.js as follows:
var WORKER_PATH = 'b.js';
var encoderWorker = new Worker('c.js');
importScripts('d.js');
I was not able to set the paths for b.js, c.js, and d.js correctly (but they all locate in the same directory!). How do I solve the problem?
Add another
<script>tag in your html:After that, you can use variable
js_b,js_c, andjs_din youra.jsJavaScript file, as they'll be strings of static paths ofb.js,c.js, andd.js.You can also get those variables from your view and return them with your RequestContext: