Search code examples
javascriptwebfilesizemaxmobile-website

Max size of a file in a mobile webpage


What can the maximum size of a JavaScript file in a website, built for mobile be? Mine was 80kb. Now I've reduced it to 43kb. Should I still have to reduce its size? What can happen if its going to be a large file?

Thank you in advance.


Solution

  • There is no 'maximum' size in any meaningful sense.

    There are a few things you want to consider when deciding on the largest acceptable size though:

    • The devices internet connection - is it on a slow GPRS (2G) connection? Or on a faster 3G/HSPA connection? For faster connections you'd have no issue with a few hundred K
    • The amount of memory in the device. If you're using a lot of images then older devices browsers will start to struggle as they run out of RAM to store the images in.
    • The degree of cachable elements is also important. If you've got a few large static CSS files, then it won't matter too much if they're used consistently because the browser will be caching them locally after the first page view. But large amounts of dynamic content can't be cached so you'll run into issues.

    There are no hard-and-fast rules on this, so you'll need to test your page on your target devices and make the judgement yourself.