'Can you save a online library in the spiffs so you can access it offline

Hallo my question is quite simple. I have made some IOT projects and U am wondering if you would be able to save e.g. a javascript library in the spiffs on the esp32 or esp8266 and then retrieve it in the browser.

The way you normally do it is like this.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

but I wonder if you can do something like this if it is saved in the spiffs and you made the right code

<script src="https://192.168. 0.1/library"></script>


Solution 1:[1]

Yes you can send save JavaScript libraries or similar in spiffs and then send it to the web page.

If anyone has problems with it here's some help. The way you do it in HTML is to write it like this.

<script src="/JQ"></script>

If you are working with ESP8266 then the code for the request should look like this

server.on("/JQ", HTTP_GET, [](AsyncWebServerRequest *request){
  request->send(SPIFFS, "/JQ.js");

Where it finds the saved file in the spiffs and sends it to client.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1