1

For some reason, I have a very small delay when I click my extension before the popup is loaded.

It's a 1-2 second hiccup before the popup displays, while all my other extensions display the popup html immediately.

loading

As you can see above, there is even the loading cursor animation when I click the popup, which never happens for the other extensions.

Here is my popup html:

<!doctype html>
<html>
  <head>
    <script type="text/javascript" src="popup.js"></script>
    <title>Add a website to block</title>
  </head>
  <body>
    <form id="addWebsiteForm">
    Website Address: <input type="text" id="websiteAddress"><br>
    <input type="submit" value="Add Website">
    </form>
  </body>
</html>

My popup.js

var addWebsiteForm;

document.addEventListener('DOMContentLoaded', function(){
  addWebsiteForm = document.getElementById("addWebsiteForm");
  addWebsiteForm.addEventListener('submit', addWebsite);
});

function addWebsite(event) {
  event.preventDefault();
  var websiteAddressInput = document.getElementById("websiteAddress");
  var websiteAddress = websiteAddressInput.value;
  var storedWebsites;

  chrome.storage.local.get('websites', function(objects) {

    if (!objects.websites) {
        storedWebsites = [];
    } else {
        storedWebsites = objects.websites;
    }

    storedWebsites.push({'address':websiteAddress});
    chrome.storage.local.set({'websites':storedWebsites});
    addWebsiteForm.reset();
    websiteAddressInput.focus();
  });
}

And my manifest:

{
  "manifest_version": 2,

  "name": "Quizlet Extension",
  "description": "Go through your flashcards before moving onto a website",
  "version": "1.0",

  "options_page":"options.html",

  "browser_action": {
    "default_icon": "icon.png",
    "default_popup": "popup.html"
  },

  "permissions": [
    "storage"
  ]
}

Any ideas?

Eric Gao
  • 3,502
  • 2
  • 19
  • 29
  • 1
    I remember a similar question.. Can you try moving your ` – Xan Oct 29 '14 at 21:09
  • No change. Actually, taking out the script line altogether gives me the same problem. – Eric Gao Oct 29 '14 at 21:27
  • I'm pretty sure it won't really be reproducible. Try to search for issues at crbug.com and maybe opening a new one. While you do, try to repoduce it on another machine / on Chrome Canary. – Xan Oct 29 '14 at 21:28
  • @user3854397 Which version of Chrome are you using? Which operating system are you using? Someone else also had an issue with the popup (http://crbug.com/421778), but unfortunately the bug report did not provide enough auctionable information. – Rob W Oct 29 '14 at 23:15
  • @RobW I am using Version 38.0.2125.111 m. I am on Windows 8.1 as well. – Eric Gao Oct 30 '14 at 07:08
  • @user3854397 Could you try earlier versions of Chrome to see if it reproduces? 1. Use 7-zip to extract the offline installer 2. Use 7-zip again to extract the resulting chrome.7z file. 3. Start chrome.exe --user-data-dir=%TMP%\whatever and load your extension. If that does not reproduce the problem, close Chrome, COPY your full user data directory from your main Chrome profile (visit chrome://version to find the location of this directory), and start the old Chrome using this directory. If the problem does not persist, then the problem is probably caused by a specific version of Chrome. – Rob W Oct 30 '14 at 09:41
  • Here are some old versions that you can try: https://robwu.nl/s/37.0.2062.124_chrome_installer.exe / https://robwu.nl/s/36.0.1985.49_chrome_installer.exe (let me know if you need more). – Rob W Oct 30 '14 at 09:43
  • The problem has actually mysteriously disappeared. I'll let you know if it comes back. – Eric Gao Oct 30 '14 at 09:45
  • Is this answer helpful? http://stackoverflow.com/questions/29191671/chrome-extension-pauses-before-loading – Ben Mar 26 '15 at 03:51
  • Possible duplicate of [my chrome extension popup opens after a few seconds, it's slow compared to other extensions](https://stackoverflow.com/questions/26276815/my-chrome-extension-popup-opens-after-a-few-seconds-its-slow-compared-to-other) – Edward Brey Jul 11 '19 at 20:12

1 Answers1

1

I think you can try to add the background params to the manifest :

{
  ...
  "background": {
    "page": "background.html",
    "persistent": true
  },
  ...
}

Of course, need add a simple html file to the extension folder :

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
  </head>
  <body>
  </body>
</html>

Now open the Chrome Extension will be quickly without no delay.

The background page will be run all the time, it is always used to show notification.So we can make use of this feature, need't reopen the Extension which is the main reason of delay

seaside
  • 11
  • 2