Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

402
Vistas
Chrome Extension Manifest V3 Libraries in Background

I'm in the process of updating my chrome extension from manifest v2 to v3. Here's the old manifest:

Manifest V2:

{
"manifest_version": 2,
"name": "Legacy Search Assistant",
"version": "0.1.1",
"content_scripts": [
    {
        "matches": [
            "https://*.legacysite.io/*","*://*/api*"
        ],
        "js": ["jquery-3.6.0.min.js","content.js"]
    }
],
"options_page": "options.html",
"background": {
    "scripts": ["jsencrypt.min.js", "jquery-3.6.0.min.js", "background.js"]
},
"browser_action": {
    "default_icon":  "icon.png",
    "default_popup": "popup.html",
    "default_title": "Legacy Search"
},
"permissions": [
    "storage"
]
}

Since jsencrypt.min.js was already loaded in the manifest I was able to call it's functions in background.js, but now that I've gone to manifest v3 I am having problems getting the service worker to access this library.

For example, when I make this call in background.js:

importScripts("/scripts/jsencrypt.min.js");

It throws the following error:

Error handling response: Error: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'chrome-extension://<extension ID>/scripts/jsencrypt.min.js' failed to load.

If I click the link in the error it takes me directly to the library I want loaded.

I've already tried all of the fixes in this answer. Please help if you can.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

importScripts() is old way to load scripts in workers.

Now we can use more modern, ES modules instead.

Starting from Chrome 91, we can use JavaScript modules in service workers.

Just set type property to module in the manifest.

{
"manifest_version": 3,
"background": {
  "service_worker": "background.js",
  "type": "module"
}

This loads the service worker as an ES module, which lets you use the import keyword in the service worker to import other modules. Ex-

// background.js
import * as module from './scripts/jsencrypt.min.js';

But make sure that the script you are importing like ./scripts/jsencrypt.min.js in this case, has exported the required code that you want to use.

Learn about ES modules

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda