Search Unity

Is it possible to reduce webgl builds to 300kb ?

Discussion in 'Web' started by Ali_V_Quest, Sep 12, 2017.

  1. Ali_V_Quest

    Ali_V_Quest

    Joined:
    Aug 2, 2015
    Posts:
    138
    Hi there,

    1. right now the empty project is about 2.3 MB, but hypothetically, if you want to develop a 2D game, can you strip most of the unity engine to generate below 1MB project ?

    2. why doesn't unity strip the engine on the class level ( not the module leve), right now it includes the full 5 MB physics module even if you use a simple Physics.Raycast ?

    Thanks.
     
  2. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,073
    1) No, sadly that is the smallest it gets at the moment.

    2) That is not a trivial thing to do. We'd really like to get there in the future though but for now this is where we're at.
     
  3. ywj7931

    ywj7931

    Joined:
    Jun 24, 2015
    Posts:
    41
    Which version of Unity are you using? My empty project builds up to 4MB
     
  4. Ali_V_Quest

    Ali_V_Quest

    Joined:
    Aug 2, 2015
    Posts:
    138
    @ywj7931 I'm using unity 2017.1 , make sure to use brotli compression instead of gzip (it slower to compress, so use it only for final builds or to test build size )
     
  5. Ali_V_Quest

    Ali_V_Quest

    Joined:
    Aug 2, 2015
    Posts:
    138
  6. ywj7931

    ywj7931

    Joined:
    Jun 24, 2015
    Posts:
    41
    But will that cause compatibility issue, some browser doesn't support brotli?
     
  7. kognito1

    kognito1

    Joined:
    Apr 7, 2015
    Posts:
    331
    In that case Unity will just decompress the payload using javascript instead of doing the decompression at the "browser level" (the end result will be a longer load time for the end user). Regardless, you can use gzip compression (supported everywhere) which will also bring it below 4MB. Currently our binary (contains only code, almost no art assets) is 3.5MB with gzip compression so it's definitely feasible.