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

173
Vistas
How do I make a content script load before another content script (that runs on the same event) in a Firefox extension?

Here's a portion of my manifest.json file:

  "content_scripts": [ {
"js": [ "common.js", "generation.js" ],
"matches": [ "*://www.site.com/*" ],
"run_at": "document_start"
},
{
"js": [ "page_init.js" ],
"matches": [ "*://www.site.com/*" ],
"run_at": "document_start"
},

Here, I want to run "common.js" before "page_init.js", as common.js contains much shared code and global variables and functions that the other content scripts need to function. I have defined common.js before page_init.js in my manifest, and, in Chrome, doing this results in common.js running before all the other content scripts, which is what I need. However, in Firefox, it doesn't seem to do this.

When I run this extension in Firefox, however, page_init throws an error:

ReferenceError: ReferenceError: href is not defined

"href" is a variable that's defined in common.js.

Do I need to make page_init.js run at document_end in order for common.js to fully run, or is there another way? I need them to both run at document_start.

UPDATE:

I managed to resolve the issue by changing the manifests contents to this:

 "content_scripts": [ 
{
"js": [ "common.js", "generation.js", "page_init.js" ],
"matches": [ "*://www.site.com/*" ],
"run_at": "document_start"
},
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

From firefox documentation:

js

An array of paths, relative to manifest.json, referencing JavaScript files that will be injected into matching pages.

Files are injected in the order given. This means that, for example, if you include jQuery here followed by another content script, like this...

It's probably a firefox bug, you may want to report it.

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