Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

201
Views
How to network throttle in iframe like we have a devtool

How to network throttle in iframe like we have in a devtool, let say want to open my own website inside iframe, and i want to throttle with a slow 3g mode how can we acheive this .

If i want to do this using chrome extension, is there any api to do this.

I have added the below code to enable the chrome debugger, but this is for the page or tab not for the particular iframe.

   await chrome.tabs.query(
      { currentWindow: true, active: true },
      function (tabs) {
        console.log("tabs--->", tabs);
        console.log(tabs[0].id);

        chrome.debugger.attach({ tabId: "8C206DBB36086B4E52EB465197CE01ED" }, "1.3", () => {
          if (chrome.runtime.lastError) {
            console.log("runtime.lastError", chrome.runtime.lastError.message);
            return;
          }
          console.log("Debugger attached");
        });

        chrome.debugger.sendCommand(
          { tabId: tabs[0].id },
          "Network.enable",
          () => {
            if (chrome.runtime.lastError) {
              console.log(
                "runtime.lastError",
                chrome.runtime.lastError.message
              );
              return;
            }
            console.log("Debugger attached");
          }
        );

        const newtworkThrottleValues = {
          offline: {
            downloadThroughput: 0,
            uploadThroughput: 0,
            latency: 0,
            offline: true,
          },
          slow3G: {
            downloadThroughput: ((500 * 1024) / 8) * 0.8,
            uploadThroughput: ((500 * 1024) / 8) * 0.8,
            latency: 400 * 5,
            offline: false,
          },
          fast3G: {
            downloadThroughput: ((1.6 * 1024 * 1024) / 8) * 0.9,
            uploadThroughput: ((750 * 1024) / 8) * 0.9,
            latency: 150 * 3.75,
            offline: false,
          },
          online: {
            downloadThroughput: -1,
            uploadThroughput: -1,
            latency: 0,
            offline: false,
          },
        };

        chrome.debugger.getTargets((result) => {
          console.log("result", result);
        });
        chrome.tabs.query(
          { currentWindow: true, active: true },
          function (tabs) {
            settabid(tabs[0].id);
            console.log(tabs[0]);
          }
        );
        chrome.debugger.sendCommand(
          { tabId: tabs[0].id },
          "Network.emulateNetworkConditions",
          newtworkThrottleValues["offline"],
          () => {
            if (chrome.runtime.lastError) {
              console.log(
                "runtime.lastError",
                chrome.runtime.lastError.message
              );
              return;
            }
            console.log("Debugger attached 3");
          }
        );
      }
    );
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

To throttle network for page we have to use tabId and for iframes we have to pass targetId in place of tabId

    chrome.tabs.query(
      { currentWindow: true, active: true },
      function async(tabs) {
        await chrome.debugger.getTargets(async (result) => {
          const d = result.filter((value) => value.url.includes("url"));
          await chrome.debugger.attach(
            { tabId: tabs[0].id,},
            "1.3",
            () => {
              if (chrome.runtime.lastError) {
                console.log(
                  "runtime.lastError",
                  chrome.runtime.lastError.message
                );
                return;
              }
              console.log("Debugger attached");
            }
          );

          await chrome.debugger.sendCommand(
            { tabId: tabs[0].id },
            "Network.enable",
            () => {
              if (chrome.runtime.lastError) {
                console.log(
                  "runtime.lastError",
                  chrome.runtime.lastError.message
                );
                return;
              }
              console.log("Debugger attached");
            }
          );

          const newtworkThrottleValues = {
            offline: {
              downloadThroughput: 0,
              uploadThroughput: 0,
              latency: 0,
              offline: true,
            },
            slow3G: {
              downloadThroughput: ((500 * 1024) / 8) * 0.8,
              uploadThroughput: ((500 * 1024) / 8) * 0.8,
              latency: 400 * 5,
              offline: false,
            },
            fast3G: {
              downloadThroughput: ((1.6 * 1024 * 1024) / 8) * 0.9,
              uploadThroughput: ((750 * 1024) / 8) * 0.9,
              latency: 150 * 3.75,
              offline: false,
            },
            online: {
              downloadThroughput: -1,
              uploadThroughput: -1,
              latency: 0,
              offline: false,
            },
          };
          await chrome.debugger.sendCommand(
            { tabId: tabs[0].id },
            "Network.emulateNetworkConditions",
            newtworkThrottleValues["offline"],
            () => {
              if (chrome.runtime.lastError) {
                console.log(
                  "runtime.lastError",
                  chrome.runtime.lastError.message
                );
                return;
              }
              console.log("Debugger attached 3");
            }
          );
        });
      }
    );
  };```
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!