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

279
Vistas
In a userscript/greasemonkey, how do you use a newer version of jQuery when the website already uses an older version?

I'm trying to write a userscript for a website that is already using an ancient version of jQuery. If I @require a modern version in the userscript, I get a console error about how a field named exists doesn't exist. Since these two versions of jQuery are incompatible, is there any way to use them both without them conflicting?

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

0

Maybe there's an even better solution than this, but here's what I've come up with: @require jQuery the way you'd normally want, then at the end of your script, put a $.noConflict();. As some of your userscript functions may need to use the latest version, it may not be enough to put $.noConflict(); as the last line. To avoid thinking about that possibility, you can write your script like this:

...
// @require https://code.jquery.com/jquery-3.6.0.min.js
// ==/UserScript==

((jQueryAsAParameter) => {
  // use jQueryAsAParameter in here, because $ may refer to the old version
  ...
})($);

$.noConflict();

This is called an IIFE if you want to learn more. The above is kind of weird. I wrote it that way to make the next example easier to understand. This achieves the same effect, but in my opinion, it's more idiomatic.

...
// @require https://code.jquery.com/jquery-3.6.0.min.js
// ==/UserScript==

(($) => {
  ...
})($);

$.noConflict();
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