-
-
Notifications
You must be signed in to change notification settings - Fork 315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Data URLs exceed length limits #372
Comments
Hey there! That's interesting. I don't think the network panel errors is a huge problem, as long as the assets load. Do they appear to be missing/broken in the saved HTML file, when the browser renders the page? |
@snshn Yes, they don't load. This is then reflected in the Network panel - The CSS file in question was several megabytes and so the data URL didn't work. The page then looked weird because it didn't have the CSS |
Uh-oh, that's a real boo-boo. Thank you for letting me know. I've done some research prior on minimizing image size, I believe that could help. What browser was it in, if I may ask? |
@snshn Modern chrome 😅 (120 I think). You can embed the string in JavaScript then create a blob URL though if it's too long, e.g: For CSS and JS you could turn |
Ideally JS should be unobtrusive, many people disable it by default (e.g. NoScript extension), and modifying the original document way too much could cause other problems (aside from blowing up the code base of Monolith), but you're suggesting very good solutions, thank you. I'll look into MHTML more, it could be a good format for solving these types of issues, but I agree that it's a big problem, I'm honestly a bit shocked there's a limit on the length in the browser, I assumed it's something like file size — as long as the machine has enough memory, it should work. |
@snshn Your project seems a lot like SingleFile, you could see how they do it |
If it's been solved in SingleFile, it's likely done the way you've described it — using JS to build blobs and unwrapping assets, embedding them into the HTML. I rather stay away from relying on JS, but if there's no better alternative, that approach is better than nothing. It still looks like a browser issue more than the tool's issue, as there's no length limit in the spec, that's just something browsers impose. I will eventually make Monolith reduce file size of embedded assets by not using base64 when not necessary, that's upcoming in future versions. I'll see how MHTML behaves and what could be done with large files (e.g. splitting one .js file into multiple consequently-included .js files, doing the same with .css assets). There's always a way. |
@snshn For all styles and scripts you can simply inline them using script and style tags instead of link/script[src]. This should solve the issue most of the time, for images you could:
|
See: https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
This leads to 404 errors in the network panel because of invalid URLs.
The text was updated successfully, but these errors were encountered: