1

I want to make a client-side application that loads JavaScript files using only script-tags, (and not fetch, due to cross-origin concerns), but I was wondering if its possible to somehow set the custom request headers in the script tag, such that I can receive only part of a file (the equivalent to sending the range: bytes 10-40 header), or other custom headers the server may request?

1 Answer 1

2

No, that's not possible. A script tag will create a regular HTTP GET request without any means to control the headers.

Sign up to request clarification or add additional context in comments.

9 Comments

oh brutal, ok then. do you know if theres some other way to read / include part of a javascript file from a cross-origin site?
What are you trying to achieve by that? Never stumbled upon such a case. Maybe save the partial js file as a new file and refer to that one on the client.
basically I have a large JS file that acts as a database for a large amount of data, it is filled with a list of function calls, each call taking up about 5-60 KB of data, one following the other. I have another file, index.js, which keeps track of the byte offset of each function call, so the idea is that when the user clicks on a certain button that is asociated with a certain number value, the data from index.js checks what byte-offset the function call necessary for that button press is associated with, and loads only part of that file. It would be massively impractical to split it up
because I have a series of these large "javascript database files", and each one could be anywhere from 500kb - 4mb, and if I split it up each one could be split up into 10-200 separate files, which would result in 20,000 files total to upload to my server (for later offline download use), as opposed to just 1,500 if I do it this way, and it takes a longer time to upload more files with less space than less files with more space
Maybe post a new question. Hope you've found my answer useful
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.