A default from the browser, which can be overridden by the user.
> How is it going to be calculated? Is it the amount of loaded files? What if the page is small but then loads more dynamically later?
Preferably by a total per-site and per page (with page being a higher amount than site). When a site/page hits its limit, halt running with a popup asking for a temporary larger limit (and a checkbox to remember the limit for this site).
> How I, as a developer, make sure my website works everywhere?
The same way you, as a developer, make sure it works everywhere with Javascript features. You find a sane maximum by the lowest of all the browsers that support it. If you figure out what IE, Chrome, Firefox and Safari (and their mobile equivalents) have as limits, you've basically solved the problem.
> What with sites that use a lot of code but still work fast? The amount of code does not directly translate to slowness.
Depending on your connection, it really does. Bad mobile connections (even if only in certain locations, like supermarkets that are constructed like Faraday cages) mean that an increase in the size of the JS loaded required to use the page directly translates into extremely slow websites, and in a lot of contexts, the first page is the only page visited, so the idea that a SPA will be quick after that first load (to stave off that future point) doesn't really solve the problem.
> What is going to be the limit?
Whatever the user wants it to be.
> Who is going to be setting it?
A default from the browser, which can be overridden by the user.
> How is it going to be calculated? Is it the amount of loaded files? What if the page is small but then loads more dynamically later?
Preferably by a total per-site and per page (with page being a higher amount than site). When a site/page hits its limit, halt running with a popup asking for a temporary larger limit (and a checkbox to remember the limit for this site).
> How I, as a developer, make sure my website works everywhere?
The same way you, as a developer, make sure it works everywhere with Javascript features. You find a sane maximum by the lowest of all the browsers that support it. If you figure out what IE, Chrome, Firefox and Safari (and their mobile equivalents) have as limits, you've basically solved the problem.
> What with sites that use a lot of code but still work fast? The amount of code does not directly translate to slowness.
Depending on your connection, it really does. Bad mobile connections (even if only in certain locations, like supermarkets that are constructed like Faraday cages) mean that an increase in the size of the JS loaded required to use the page directly translates into extremely slow websites, and in a lot of contexts, the first page is the only page visited, so the idea that a SPA will be quick after that first load (to stave off that future point) doesn't really solve the problem.