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?
Add a comment
|
1 Answer
No, that's not possible. A script tag will create a regular HTTP GET request without any means to control the headers.
9 Comments
B''H Bi'ezras -- Boruch Hashem
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?
Arik
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.
B''H Bi'ezras -- Boruch Hashem
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
B''H Bi'ezras -- Boruch Hashem
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
Arik
Maybe post a new question. Hope you've found my answer useful
|