Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for WebAssembly
  4. zip binaries
Forum Updated to NodeBB v4.3 + New Features

zip binaries

Scheduled Pinned Locked Moved Unsolved Qt for WebAssembly
5 Posts 4 Posters 785 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jan Bakker
    wrote on last edited by
    #1

    I read about shrinking the wasm file with gzip. With zip/gzip/rar the file is indeed considerably smaller. I don't understand how to implement that in my project. I assume I need to download the compressed file and decompress it locally with qtloader.js? Does anyone have experience with that and does it minimize the waiting time? And of course an example is appreciated.

    R E 2 Replies Last reply
    0
    • J Jan Bakker

      I read about shrinking the wasm file with gzip. With zip/gzip/rar the file is indeed considerably smaller. I don't understand how to implement that in my project. I assume I need to download the compressed file and decompress it locally with qtloader.js? Does anyone have experience with that and does it minimize the waiting time? And of course an example is appreciated.

      R Offline
      R Offline
      RandomGuy
      wrote on last edited by
      #2

      @Jan-Bakker The compression is done in the webserver, like apache. I recommend brotli compression as that is superior to gzip.

      1 Reply Last reply
      0
      • J Jan Bakker

        I read about shrinking the wasm file with gzip. With zip/gzip/rar the file is indeed considerably smaller. I don't understand how to implement that in my project. I assume I need to download the compressed file and decompress it locally with qtloader.js? Does anyone have experience with that and does it minimize the waiting time? And of course an example is appreciated.

        E Offline
        E Offline
        Exter1950
        wrote on last edited by
        #3

        @Jan-Bakker said in zip binaries traffic Jam 3D:

        I read about shrinking the wasm file with gzip. With zip/gzip/rar the file is indeed considerably smaller. I don't understand how to implement that in my project. I assume I need to download the compressed file and decompress it locally with qtloader.js? Does anyone have experience with that and does it minimize the waiting time? And of course an example is appreciated.

        Yes, compressing your WASM file with gzip can significantly reduce its size and improve loading times. Example of how to load and decompress a compressed WASM file with pako:

        import pako from 'pako';
        
        fetch('my-wasm-file.wasm.gz')
          .then(response => response.arrayBuffer())
          .then(buffer => {
            const decompressedData = pako.inflate(new Uint8Array(buffer));
            const wasmModule = new WebAssembly.Module(decompressedData);
            const wasmInstance = new WebAssembly.Instance(wasmModule);
            // Use wasmInstance here
          });
        
        

        This code will load the compressed WASM file 'my-wasm-file.wasm.gz', decompress it using pako, and then instantiate the WASM module. Once the module is instantiated, you can access its exported functions and properties using wasmInstance.

        Compressing and decompressing the WASM file will add some overhead to the loading process, but it will still be faster than loading the uncompressed file, especially for larger WASM files. The exact difference in loading time will depend on the size of the WASM file and the performance of your browser.

        R 1 Reply Last reply
        1
        • E Exter1950

          @Jan-Bakker said in zip binaries traffic Jam 3D:

          I read about shrinking the wasm file with gzip. With zip/gzip/rar the file is indeed considerably smaller. I don't understand how to implement that in my project. I assume I need to download the compressed file and decompress it locally with qtloader.js? Does anyone have experience with that and does it minimize the waiting time? And of course an example is appreciated.

          Yes, compressing your WASM file with gzip can significantly reduce its size and improve loading times. Example of how to load and decompress a compressed WASM file with pako:

          import pako from 'pako';
          
          fetch('my-wasm-file.wasm.gz')
            .then(response => response.arrayBuffer())
            .then(buffer => {
              const decompressedData = pako.inflate(new Uint8Array(buffer));
              const wasmModule = new WebAssembly.Module(decompressedData);
              const wasmInstance = new WebAssembly.Instance(wasmModule);
              // Use wasmInstance here
            });
          
          

          This code will load the compressed WASM file 'my-wasm-file.wasm.gz', decompress it using pako, and then instantiate the WASM module. Once the module is instantiated, you can access its exported functions and properties using wasmInstance.

          Compressing and decompressing the WASM file will add some overhead to the loading process, but it will still be faster than loading the uncompressed file, especially for larger WASM files. The exact difference in loading time will depend on the size of the WASM file and the performance of your browser.

          R Offline
          R Offline
          RandomGuy
          wrote on last edited by
          #4

          @Exter1950 Interesting I didn't think it was possible to do it directly with javascript.

          1 Reply Last reply
          0
          • JasonWongJ Offline
            JasonWongJ Offline
            JasonWong
            wrote on last edited by
            #5

            Do not manually compress these files; you can leave it to Nginx to handle automatically. After adding these configurations to my Nginx conf file, automatic compression is enabled:

                gzip on;
                gzip_min_length 32k;
                gzip_buffers 4 16k;
                gzip_http_version 1.1;
                gzip_comp_level 2;
                gzip_types text/plain text/css text/xml application/xml application/json text/javascript application/javascript application/octet-stream;
            

            You can visit this address to see the compression effect. Open the F12 console in Chrome, and you will notice that the wasm file has been compressed.
            https://web.jasonserver.com:10035/JQClock/JQClock.html

            1 Reply Last reply
            3

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved