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

146
Views
Why does the location of adding the onClicked listener affect the speed of the code?

Both versions of this code add an event listener to a context menu item. I was wondering what the differences were, and why version 1 is always loading the popup 5x faster than version 2.


Version 1 (Fast):

chrome.runtime.onInstalled.addListener(() => {
    chrome.contextMenus.create({
        id: "create-popup-from-page",
        title: "Popup From Page",
        contexts: ["all"],
    });
});
chrome.contextMenus.onClicked.addListener((pageUrl) => {
    createPopupFromUrl(pageUrl.pageUrl.toString());
});

Version 2 (Slow):

chrome.runtime.onInstalled.addListener(() => {
    chrome.contextMenus.create({
        id: "create-popup-from-page",
        title: "Popup From Page",
        contexts: ["all"],
    });
    chrome.contextMenus.onClicked.addListener((pageUrl) => {
        createPopupFromUrl(pageUrl.pageUrl.toString());
    });
});
about 4 years ago · Juan Pablo Isaza
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!