I’m planning to upgrade my shopping website so that people who are stuck on the highway in the middle of nowhere with lousy internet who want to make purchases can see a progress bar moving instead of a screen with no activity (while square.js and friends load).
If I do not tell the square server that I support gzip compression, the content-length is returned in the HTTP header (which is what I need to make the progress bar work).
If I do tell the server that I support gzip (which is what most web browsers automatically do), then the content-length is NOT returned and the progress bar won’t work.
I still would need it for the gzipped response because the javascript after compression weighs in at about 110KB and if that person under a rock with lousy internet with say a download speed of dialup (57600 bits/second or 7200 bytes/second) is trying to buy something quickly, he would have to wait a minimum of 15 seconds just for the square script to load. this excludes all of the other resources necessary to enable the customer to make an electronic purchase.
Would you be able to change this at your end, or would I have to setup my server to periodically download square.js to make it in sync with the version on the square site so that when customers order from me, I can serve them the local square.js with the content-length always included in the header?
Sorry, its just people these days are impatient and they don’t want to wait 15 seconds at a blank screen.
I have already considered the idea of hosting the js locally but depending on the user browser’s settings, the payload per request goes from 0-300 KB. Most of my web pages require less than 30 KB download uncompressed for it to be complete.
I complain about the size because some hosting providers may charge an overage fee if the amount of data downloaded in one month exceeds a certain value and 300 KB can add up pretty quickly given all other webpage items are no more than 3 - 50 KB each.
Hello,
Serve Local Copy of square.js:
You can periodically download the latest version of square.js from the Square CDN and serve it from your server. This way, you can ensure that the Content-Length header is always included, even for gzipped responses.
You can set up a cron job or a scheduled task to download the latest version of square.js at regular intervals and store it on your server.
Use a Service Worker:
Implement a service worker to cache the square.js file locally. This way, once the file is downloaded, it can be served from the cache for subsequent requests, reducing the load time significantly.
Service workers can also provide a fallback mechanism to show a progress bar or a loading indicator while the file is being fetched.
Custom Loading Indicator:
While the file is being downloaded, you can show a custom loading indicator or a progress bar based on the estimated download time. You can calculate the estimated time using the file size and the user’s connection speed. choiceADVANTAGE