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

229
Views
¿Cómo cargar scripts javascript cdn en componente en lugar de index.html?

Tengo tres scripts en index.html en la carpeta pública:

 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-zoom/1.6.1/jquery.zoom.min.js"></script> <script> $(document).ready(function () { $("#ex1").zoom(); }); </script>

Y en el componente tengo una imagen que funciona con estos scripts:

 import React from "react"; import "./Home.css"; function Home() { return ( <React.Fragment> <div class="zoom" id="ex1"> <img src="https://i.pinimg.com/736x/3e/3e/49/3e3e49c8e76076f09ef1170a95b09cfb.jpg" class="img" alt="Daisy on the Ohoopee" /> </div> </React.Fragment> ); } export default Home;

Quiero tener todos los scripts en el componente exacto pero no sé cómo.

¿Cómo puedo mover todas las secuencias de comandos de index.html en la carpeta pública a mi componente de reacción?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede crear el script dinámicamente:

 useEffect(()=>{ const script = document.createElement("script"); script.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"; script.async = true; document.body.appendChild(script); },[]);

pero no se recomienda cargar scripts dentro del componente.

about 4 years ago · Juan Pablo Isaza Report
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!