<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ali Qayyum</title>
    <description>The latest articles on DEV Community by Ali Qayyum (@aliqayyum).</description>
    <link>https://dev.to/aliqayyum</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4285737%2F53618a3a-cacd-450b-8e9e-8d6bf33ee73f.jpg</url>
      <title>DEV Community: Ali Qayyum</title>
      <link>https://dev.to/aliqayyum</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aliqayyum"/>
    <language>en</language>
    <item>
      <title>PageSpeed still flags your WebP images? The 0.167 bytes-per-pixel rule, and the free tools we built around it</title>
      <dc:creator>Ali Qayyum</dc:creator>
      <pubDate>Sun, 06 Dec 2026 05:13:01 +0000</pubDate>
      <link>https://dev.to/aliqayyum/pagespeed-still-flags-your-webp-images-the-0167-bytes-per-pixel-rule-and-the-free-tools-we-built-17h4</link>
      <guid>https://dev.to/aliqayyum/pagespeed-still-flags-your-webp-images-the-0167-bytes-per-pixel-rule-and-the-free-tools-we-built-17h4</guid>
      <description>&lt;p&gt;We run a mobile accessories shop in Lahore, &lt;a href="https://www.mobilegeeks.pk/" rel="noopener noreferrer"&gt;mobilegeeks.pk&lt;/a&gt;, on WordPress and WooCommerce. Like most shop owners, we converted our product photos to WebP and expected PageSpeed Insights to stop complaining about images.&lt;/p&gt;

&lt;p&gt;It didn't. Some images were still listed under &lt;strong&gt;"Improve image delivery"&lt;/strong&gt;, even though they were already WebP. This time the advice was "increase the compression".&lt;/p&gt;

&lt;p&gt;So we read the code that makes the decision, wrote down the rules, and built two free things from them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Lighthouse Image Check&lt;/strong&gt;, a browser tool: drop an image in and it tells you if PageSpeed will flag it, then makes a copy that passes. Nothing is uploaded. &lt;a href="https://www.mobilegeeks.pk/lighthouse-image-check/" rel="noopener noreferrer"&gt;https://www.mobilegeeks.pk/lighthouse-image-check/&lt;/a&gt; (&lt;a href="https://github.com/mobilegeekspk/lighthouse-image-check" rel="noopener noreferrer"&gt;code, MIT&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MG Image Optimizer&lt;/strong&gt;, a WordPress plugin that applies the same rule to every image on a site, on your own server. &lt;a href="https://www.mobilegeeks.pk/image-optimizer/" rel="noopener noreferrer"&gt;https://www.mobilegeeks.pk/image-optimizer/&lt;/a&gt; (&lt;a href="https://github.com/mobilegeekspk/mg-image-optimizer" rel="noopener noreferrer"&gt;code, GPL&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This post covers the rule, and three things we got wrong while building the plugin.&lt;/p&gt;

&lt;h2&gt;
  
  
  The rule: bytes per pixel, for every format
&lt;/h2&gt;

&lt;p&gt;PageSpeed Insights, Lighthouse and the Chrome DevTools Performance panel share one check. Its source is &lt;a href="https://github.com/ChromeDevTools/devtools-frontend/blob/main/front_end/models/trace/insights/ImageDelivery.ts" rel="noopener noreferrer"&gt;&lt;code&gt;ImageDelivery.ts&lt;/code&gt;&lt;/a&gt; in the DevTools repository. Reduced to what matters (we read it on 6 December 2026):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;TARGET_BYTES_PER_PIXEL_AVIF&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="c1"&gt;// ≈ 0.167&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;BYTE_SAVINGS_THRESHOLD&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4096&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                  &lt;span class="c1"&gt;// ignore savings under 4 KB&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;BYTE_SAVINGS_THRESHOLD_RESPONSIVE_BREAKPOINTS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;12288&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What these mean in practice:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Every image gets a budget of width × height × 0.167 bytes.&lt;/strong&gt; That is about what a well-compressed AVIF needs, and the budget is the same whatever format the file is in.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Over budget, the advice depends on the format.&lt;/strong&gt; A JPEG or PNG gets "use a modern format". A WebP or AVIF gets "increase the compression". Converting to WebP does not get you a pass on its own.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Savings under 4,096 bytes are ignored&lt;/strong&gt;, so small icons rarely show up.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Files bigger than their box are flagged too.&lt;/strong&gt; The wasted share is 1 − displayed pixels ÷ file pixels. On a phone test, displayed pixels include the 1.75× screen density. If the image already has &lt;code&gt;srcset&lt;/code&gt; or &lt;code&gt;&amp;lt;picture&amp;gt;&lt;/code&gt;, it is only listed when the waste is above 12 KB.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A worked example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The photo:&lt;/strong&gt; 1200 × 800 pixels = 960,000 pixels.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The budget:&lt;/strong&gt; 960,000 × 0.167 ≈ 160 KB.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A 230 KB JPEG&lt;/strong&gt; is flagged: "use a modern format", about 70 KB to save.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A 135 KB WebP&lt;/strong&gt; of the same photo passes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A 300 KB WebP at 1600 × 1067&lt;/strong&gt; is flagged: "increase the compression". Its budget is about 285 KB.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The last case is the one that surprised us. A lot of "convert to WebP" plugins and CDNs use a fixed quality, such as 80 or 82, for every image. A detailed product photo at quality 82 can easily go over 0.167 bytes per pixel.&lt;/p&gt;

&lt;h2&gt;
  
  
  The tool: the rule in about 120 lines of JavaScript
&lt;/h2&gt;

&lt;p&gt;The core is a small UMD file with no dependencies. It runs in the browser and in Node, and 18 plain-Node tests cover it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="no"&gt;TARGET_BPP&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;budget&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="no"&gt;TARGET_BPP&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;TARGET_BPP&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;issues&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;isWebpOrAvif&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'compression'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'format'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;savings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;bytes&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;budget&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"Fix it" draws the image on a canvas at the width you need. It then searches for the highest quality whose file still fits a slightly lower target, 0.14 bytes per pixel, so small measurement differences don't push it back over the line. It tries AVIF if your browser can encode it, otherwise WebP. In Chrome, a 290 KB JPEG became a 129 KB WebP that passes. Told the image is shown 300 px wide, it made a 24 KB file.&lt;/p&gt;

&lt;p&gt;Everything stays in the browser. On a privacy-sensitive page, "we never see your images" is easier to promise when there is no server code at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  The plugin, and three things we got wrong
&lt;/h2&gt;

&lt;p&gt;The plugin does the same job site-wide. It compresses on your own server (Imagick or GD) and makes WebP and AVIF copies of every thumbnail size. When a copy is over the budget, it lowers the quality step by step, never below a safe floor. Copies are served with &lt;code&gt;&amp;lt;picture&amp;gt;&lt;/code&gt;, so it is safe behind page caches and Cloudflare.&lt;/p&gt;

&lt;p&gt;The bytes-per-pixel part was the easy part. These three took longer.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. The theme's &lt;code&gt;sizes&lt;/code&gt; attribute was lying
&lt;/h3&gt;

&lt;p&gt;On phones, our product grid images were shown much narrower than the theme's &lt;code&gt;sizes&lt;/code&gt; hint said. The browser believed the hint, picked a large file from &lt;code&gt;srcset&lt;/code&gt;, and PageSpeed reported the waste.&lt;/p&gt;

&lt;p&gt;Rather than guess, the plugin now measures. On a share of visits (30% by default), a small script records how wide each image is actually shown and sends one short report to the site's own REST API. The plugin then writes that width into &lt;code&gt;sizes&lt;/code&gt;, per page type and per placement. No cookies, no IP storage, nothing sent anywhere else.&lt;/p&gt;

&lt;p&gt;Our first version measured with &lt;code&gt;getBoundingClientRect()&lt;/code&gt; on every image. In PageSpeed that showed up as a "Forced reflow" of about 50 ms, which is the kind of thing the plugin is supposed to fix. Version 1.2.2 uses an &lt;code&gt;IntersectionObserver&lt;/code&gt; instead: widths come from the browser's normal rendering, images are measured as the visitor scrolls near them, and one report is sent when the page is hidden.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. The same photo, two widths
&lt;/h3&gt;

&lt;p&gt;The same product photo can appear large in the gallery and small in a sticky "add to cart" bar. Version 1.2.0 stored one width per file, so the small placement sometimes got the large file. Version 1.2.1 stores the width per placement.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Clearing one page cleared every page
&lt;/h3&gt;

&lt;p&gt;Whenever the plugin made a new copy, or learned new widths, it asked WP Rocket to clear the cached page. For the homepage, that meant deleting the homepage's cache folder. WP Rocket keeps every other page's cache folder inside the homepage's folder, so clearing the homepage deleted the whole site's cache, as often as every 10 minutes. Pages were rarely served from cache, which made the site slower, the opposite of the goal.&lt;/p&gt;

&lt;p&gt;Versions 1.2.3 and 1.2.4 clear only the pages that showed the image. For the homepage they use WP Rocket's homepage-only clean. If your plugin clears caches from background jobs, check what "clear this URL" actually deletes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try them
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Check an image: &lt;a href="https://www.mobilegeeks.pk/lighthouse-image-check/" rel="noopener noreferrer"&gt;https://www.mobilegeeks.pk/lighthouse-image-check/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;WordPress plugin: &lt;a href="https://www.mobilegeeks.pk/image-optimizer/" rel="noopener noreferrer"&gt;https://www.mobilegeeks.pk/image-optimizer/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both are free. There is no account, no API key and no upsell. Issues and pull requests are welcome on GitHub. If PageSpeed flags an image that our tool says passes, I would like to see it: usually the site is sending a different file than the one that was tested, but if our rule is wrong I want to fix it.&lt;/p&gt;

</description>
      <category>webperf</category>
      <category>wordpress</category>
      <category>javascript</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Why a 20,000 mAh power bank doesn't give 4 charges, and the English/Urdu calculator we built to show it</title>
      <dc:creator>Ali Qayyum</dc:creator>
      <pubDate>Sun, 06 Dec 2026 03:39:43 +0000</pubDate>
      <link>https://dev.to/aliqayyum/why-a-20000-mah-power-bank-doesnt-give-4-charges-and-the-englishurdu-calculator-we-built-to-14o4</link>
      <guid>https://dev.to/aliqayyum/why-a-20000-mah-power-bank-doesnt-give-4-charges-and-the-englishurdu-calculator-we-built-to-14o4</guid>
      <description>&lt;p&gt;We run a mobile accessories shop in Lahore, and customers ask us: "This power bank is 20,000 mAh and my phone is 5,000 mAh, so I get four charges, right?"&lt;/p&gt;

&lt;p&gt;The real answer is closer to two and a half to three. So we built a small calculator that shows the reason as well as the number. It works in English and Urdu, it's free, and the code is MIT-licensed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Live tool:&lt;/strong&gt; &lt;a href="https://www.mobilegeeks.pk/power-bank-calculator/" rel="noopener noreferrer"&gt;https://www.mobilegeeks.pk/power-bank-calculator/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code:&lt;/strong&gt; &lt;a href="https://github.com/mobilegeekspk/power-bank-backup-calculator" rel="noopener noreferrer"&gt;https://github.com/mobilegeekspk/power-bank-backup-calculator&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This post covers the maths, and three implementation problems that took more time than the maths: right-to-left Urdu with numbers inside it, share links that don't create duplicate pages, and running inside a heavily cached WordPress site.&lt;/p&gt;

&lt;h2&gt;
  
  
  The maths: compare energy, not mAh
&lt;/h2&gt;

&lt;p&gt;A mAh number only means something together with its voltage.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The power bank:&lt;/strong&gt; its cells are rated at about 3.6–3.7 V (Li-ion nominal voltage, see &lt;a href="https://batteryuniversity.com/article/bu-205-types-of-lithium-ion" rel="noopener noreferrer"&gt;Battery University BU-205&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The phone:&lt;/strong&gt; phone batteries are usually listed at about 3.85 V. Lenovo/Motorola's battery compliance table is one public source.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So we convert both to watt-hours (the IATA guidance uses the same formula, Wh = V × Ah):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Wh = mAh × nominal cell voltage ÷ 1000
full charges = power bank Wh × efficiency ÷ phone Wh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Efficiency is applied &lt;strong&gt;once&lt;/strong&gt;, end to end. It covers the power bank stepping its cells up to USB voltage, the cable, and the phone's own charging circuit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Our range is 60–75%.&lt;/strong&gt; Here is where it comes from:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Power bank stage:&lt;/strong&gt; Xiaomi rates a 37 Wh bank at no less than 5,500 mAh at 5 V, which is about 74%. Anker's support article estimates 80–85%.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Phone stage:&lt;/strong&gt; Anker estimates 80–90%.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Combined:&lt;/strong&gt; multiplied together, that is roughly 59–77%.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We had previously used 60–80%, but couldn't find a source for the top end, so we lowered it. Every assumption can be edited in the tool, and each one lists its source.&lt;/p&gt;

&lt;p&gt;A worked example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Power bank:&lt;/strong&gt; 20,000 mAh × 3.7 V = 74 Wh.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Phone:&lt;/strong&gt; 5,000 mAh × 3.85 V = 19.25 Wh.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Result:&lt;/strong&gt; 74 × 0.60–0.75 ÷ 19.25 = &lt;strong&gt;2.3–2.9 full charges&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;People often use the USB voltage by mistake: "10,000 mAh at 5 V" overstates the stored energy by about 35%. The tool refuses 5, 9, 12, 15, 20 and 28 V in the cell-voltage box and explains why.&lt;/p&gt;

&lt;p&gt;The core is a small UMD file with no dependencies. The tests are plain Node, and the check we started from is part of them: 40 Wh bank, 20 Wh phone, 70–80% → 1.4–1.6.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem 1: numbers inside right-to-left Urdu
&lt;/h2&gt;

&lt;p&gt;Urdu is written right to left; numbers and units like "Wh" are not. A sentence such as "40 Wh والا پاور بینک … 1.4–1.6 بار" can come out scrambled when the browser lays it out. The range may appear as "1.6–1.4", or the unit may jump to the wrong side of the number.&lt;/p&gt;

&lt;p&gt;Two things fixed it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Every number goes in its own &lt;code&gt;&amp;lt;bdi dir="ltr"&amp;gt;…&amp;lt;/bdi&amp;gt;&lt;/code&gt; element, &lt;strong&gt;together with its unit&lt;/strong&gt;, so "28.0–32.0 Wh" is a single left-to-right unit.&lt;/li&gt;
&lt;li&gt;Inside the translated strings, each placeholder is wrapped in Unicode isolate characters: LRI &lt;code&gt;⁦&lt;/code&gt; … PDI &lt;code&gt;⁩&lt;/code&gt;. These protect the numbers in text that never becomes HTML, such as &lt;code&gt;aria-label&lt;/code&gt; values and copied text.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The whole widget switches &lt;code&gt;dir&lt;/code&gt; and &lt;code&gt;lang&lt;/code&gt; when you press "اردو". Layout uses CSS logical properties (&lt;code&gt;margin-inline-start&lt;/code&gt; and so on), so almost no RTL-specific CSS was needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem 2: share links that don't create new pages
&lt;/h2&gt;

&lt;p&gt;Users wanted to send a result to a friend. The obvious approach, &lt;code&gt;?bank=20000&amp;amp;phone=…&lt;/code&gt;, gives search engines an endless supply of almost-identical URLs.&lt;/p&gt;

&lt;p&gt;We put the state in the &lt;strong&gt;URL fragment&lt;/strong&gt; instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/power-bank-calculator/#pbbc=1&amp;amp;a=mah:20000:3.7&amp;amp;p=mah:5000:3.85&amp;amp;e=60-75&amp;amp;l=ur
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Browsers never send the fragment to the server. So search engines, Cloudflare and the page cache all see a single URL, and the page reads its state back from the fragment when it opens. The old &lt;code&gt;?bank=&lt;/code&gt; links from the previous version still work: the new code reads them too, so nothing that was already shared breaks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem 3: surviving the cache plugin
&lt;/h2&gt;

&lt;p&gt;The live site uses WP Rocket with "Remove unused CSS" and "Delay JavaScript". Both break widgets that build their HTML in JavaScript:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Remove unused CSS&lt;/strong&gt; looks at the page's HTML before the script runs, decides the calculator's CSS is unused, and removes it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delay JavaScript&lt;/strong&gt; holds every script until the visitor's first tap, so the calculator would show an empty box until then.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The plugin now registers its own exclusions through WP Rocket's filters (&lt;code&gt;rocket_rucss_safelist&lt;/code&gt; with &lt;code&gt;.pbbc-(.*)&lt;/code&gt;, &lt;code&gt;rocket_delay_js_exclusions&lt;/code&gt;) and marks its script tags with &lt;code&gt;nowprocket&lt;/code&gt;. A useful lesson for anyone building widgets: don't rely on site owners to configure exclusions; ship them with the plugin.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it or reuse it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;WordPress:&lt;/strong&gt; use the shortcode &lt;code&gt;[power_bank_calculator]&lt;/code&gt;. Options are &lt;code&gt;lang="ur"&lt;/code&gt;, &lt;code&gt;shop_category&lt;/code&gt; (WooCommerce suggestions) and &lt;code&gt;analytics="0"&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No WordPress:&lt;/strong&gt; a single offline HTML file is attached to the GitHub release.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Phone list:&lt;/strong&gt; it covers 99 models sold in Pakistan.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you know a better public source for end-to-end charging efficiency, or you find a phone whose battery data is wrong, please open an issue on GitHub.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>wordpress</category>
      <category>webdev</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
