+ 4

How to load css file from zip file without extract using javascript, jQuery ?

18th Aug 2024, 10:01 AM
Raja
Raja - avatar
2 odpowiedzi
+ 3
Loading a CSS file directly from a zip archive using JavaScript or jQuery is not straightforward because JavaScript running in the browser does not have native support for reading and parsing zip files directly. However, you can achieve this using the following approach: Use a JavaScript library to handle zip files, such as JSZip. JSZip allows you to read zip files in the browser. Load and parse the zip file to extract the CSS content. Create and append a <style> element with the CSS content to the document.
18th Aug 2024, 10:24 AM
Melkon
Melkon - avatar
+ 2
Have you tried minifiying the CSS file? just thought it'd be more simple of an option to reduce file size rather than having to extract it out of a ZIP file before use. We haven't yet discussed possibilities like password protected ZIP file, corrupted ZIP file, browser's cache mechanism etc. Such possibilities may disrupt page load or fail the intended styling. A missing, or corrupted CSS file (plain or minified) on the other hand, will most likely trigger less issue cause browsers are built to anticipate such events.
18th Aug 2024, 10:56 AM
Ipang