Skip to content

Make the bundle smaller than 20M #2

Closed

Description

@adamziel

The largest files to load for the initial paint are:

  • wp.data – 13M – the WordPress installation and all its php files
  • php-web.wasm – 6.2M – the WebAssembly PHP build
  • wp.js – 182k – the emscripten-generated JS loader for wp.data
  • php-web.js – 153k – the emscripten-generated JS loader for php-web.wasm
  • php-webworker.js – 153k – same as above, but for the webworker backend

Let's shrink them as much as possible.

Here's a few ideas:

  • Minify the variable names in the PHP files
  • Minify the JSON files
  • Remove non-english translations
  • Identify PHP dependencies to remove, e.g. libxml2 doesn't seem necessary
    • libxml2 was removed from the default build in db0a477
  • Compress the .data and .wasm files using brotli compression – props to @eliot-akira. Edit: Web servers take care of it and most browsers support the brotli compression!
  • Consider disabling script/style concatenation #39 – done in Don't include static files in the build. #43 – reduced wp.data from 43M to 13M!
  • Minify the PHP files
  • Remove themes other than twentytwentytwo
  • Remove unminified JS and CSS files
  • Remove the .eot, .gif, .htaccess, .md, .mp4, .png, .scss, .stylelintignore, .svg, .ttf, .txt, .woff, and .woff2 files

Activity

  1. adamziel commented on Sep 2, 2022

    @adamziel
    CollaboratorAuthor

    The file extensions seen inside of the bundle are:

    ; find ./ -type f  | awk -F '.' '{print $NF}' | sort | uniq
    //wp-includes/sodium_compat/LICENSE
    crt
    css
    eot
    gif
    htaccess
    html
    jpg
    js
    json
    md
    mp4
    php
    png
    scss
    stylelintignore
    svg
    ttf
    txt
    woff
    woff2
    xml
    
  2. changed the title [-]Make the bundle smaller than 50mb[/-] [+][Browser] Make the bundle smaller than 50mb[/+] on Sep 22, 2022
  3. eliot-akira commented on Oct 3, 2022

    @eliot-akira
    Collaborator

    Here's an idea I saw today in Golang's documentation about reducing the size of WASM files.

    https://github.com/golang/go/wiki/WebAssembly#reducing-the-size-of-wasm-files

    They recommend brotli compression, which produces the smallest file size compared to others (gzip or zopfli).

    EDIT: Oops, never mind - this issue is about the file wp.data, which is not a WASM binary. Leaving the comment here anyway, the information could be useful elsewhere.

  4. changed the title [-][Browser] Make the bundle smaller than 50mb[/-] [+][Browser] Make the bundle smaller than 13M[/+] on Oct 14, 2022
  5. changed the title [-][Browser] Make the bundle smaller than 13M[/-] [+][Browser] Make the bundle smaller than 20M[/+] on Oct 14, 2022
  6. adamziel commented on Oct 15, 2022

    @adamziel
    CollaboratorAuthor

    @eliot-akira I just played with brotli compression and the results are impressive:

    • php-web.wasm went from 6.2M to 1.5M (gzip gives 2.2M)
    • wp.data went from 13M to 3.3M (gzip gives 5.2M)

    https://caniuse.com/brotli says it's supported on most major browsers – it shouldn't be that hard to serve brotli-compressed version of this files by default and offer a gzip fallback for unsupported browsers.

  7. eliot-akira commented on Oct 15, 2022

    @eliot-akira
    Collaborator

    Cool! Glad the information about brotli turned out to be useful. Just saw PR #43, amazing.

  8. changed the title [-][Browser] Make the bundle smaller than 20M[/-] [+]Make the bundle smaller than 20M[/+] on Oct 22, 2022
  9. krishenriksen commented on Nov 4, 2022

    @krishenriksen

    Brotli compress/decompress of php.wasm + wp.data

    php.wasm - 1.58 MB
    wp.data - 1.44 MB

    #66

    It loads fast enough now for you to even remove the Progress Bar.

  10. adamziel commented on Nov 23, 2022

    @adamziel
    CollaboratorAuthor

    We're down to 3MB - 4MB for both php.wasm and wp.data! The actual bundles are about 15MB at the moment, but the webservers apply Brotli compression which dramatically reduces the amount of data transferred over the wire. Furthermore, #66 explores Brotli at JavaScript level to support non-webserver environments and more aggressive compression levels.

    I'm going to close this issue for now, feel free to reopen at any point if needed.

  11. added a commit that references this issue on Feb 6, 2024
  12. added a commit that references this issue on Feb 6, 2024
  13. added a commit that references this issue on Apr 11, 2026
    51af4d2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions