title: Storing same data into storage.sync, Chrome uses much more quota than Firefox
body: <h2><strong>Background</strong></h2>
  <p>I'm working on <a href="https://github.com/garywill/bigSearch" rel="nofollow noreferrer"><strong>a browser addon (webextension API)</strong></a>, which is cross-browser (Firefox &amp; Chromium/Chrome/Blink).</p>
  <p>I need to use <code>browser.storage.sync</code> (<code>chrome.storage.sync</code> on Chrome) to storage so that data can be synced.</p>
  <p><code>storage.sync</code> limits storage size (128kB), so I've tried these JS compressing library:</p>
  <ul>
  <li><p><a href="https://github.com/rotemdan/lzutf8.js" rel="nofollow noreferrer">lzutf8</a> (LZ77 algorithm)</p>
  </li>
  <li><p><a href="https://pieroxy.net/blog/pages/lz-string/index.html" rel="nofollow noreferrer">lz-string</a> (LZW algorithm)</p>
  </li>
  </ul>
  <p>(<code>lzutf8</code> compression results a smaller size)</p>
  <h2><strong>Using the compress library</strong></h2>
  <p>Above two both support <code>uint8Array</code> output, but when I tried storing <code>uint8Array</code> into <code>storage.sync</code> they got about 10 times bigger, obviously not really stored in <code>uint8</code> format.</p>
  <p>Then I found compressing to string is the best way to store:</p>
  <pre><code>Y1 = LZUTF8.compress(input-data, {outputEncoding: &quot;StorageBinaryString&quot;});
  </code></pre>
  <pre><code>Y2 = LZString.compressToUTF16(input-data)
  </code></pre>
  <p>( Both Y are UTF16 string )</p>
  <h2><strong>Question</strong></h2>
  <p>Storing the compressed data Y (string) into Firefox (78) and Chromium (90), <strong>the space it occupies in <code>storage.sync</code> different</strong>:</p>
  <ul>
  <li><strong>in Firefox:</strong> Bytes used = <code>Y.length</code>.</li>
  <li><strong>in Chromium:</strong> Bytes used = about 2-3 times larger than <code>Y.length</code>. <strong>WHY?</strong></li>
  </ul>
  <p>(The space used can be seen by <code>storage.sync.getBytesInUse()</code>. Both Firefox and Chromium have limitation of same quata: 128k bytes)</p>
  <p>I need some explaination. I can't find any doc about how (and what object type) data is stored in <code>storage.sync</code>. Also, I'll appriciate if there is better compressing and storaging (sync supported) solution.</p>