I’m working in vanilla JS (I might convert the code to JQuery but we’ll see) and I’d like to have a file in the same folder as the JS file (this file would be publicly accessible) simply containing a bunch of data for the JS script to work with. I’d rather not have all the data hard-coded into the script for a number of reasons.
The data can be loaded immediately at beginning of run-time and isn’t dynamic at all. I was hoping I could pass it in as a dependency but that doesn’t seem to work.
Right now as a compromise I hard coded it into a different script which sets a variable and loaded that script before the main script which then accesses that variable as a global (you can probably understand why I hate the state it’s currently in lol)
Using fetch
doesn’t work locally due to CORS issue and I’d really rather not try and get it via a HTTP request due to needing to hard-code the URI. If the data file is being served anyway, I really don’t see why this needs to be so difficult…