Created
March 13, 2020 08:56
-
-
Save ekzGuille/da25330f034f1f2b2ab7557be77ebcbb to your computer and use it in GitHub Desktop.
Añadir HTML desde javascript en una única línea. PRO MODE ENABLED 😎
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PRO TIP: Crear HTML Element + asignar valores en una sola linea | |
// Varias ejecuciones (metodo antiguo) | |
const script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.src = './script.js'; | |
document.body.appendChild(script); | |
// Una sola ejecucion (metodo PRO 😎) | |
document.body.appendChild( | |
Object.assign(document.createElement('script'), { | |
type: 'text/javascript', | |
src: './script.js' | |
}) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment