Skip to content

Instantly share code, notes, and snippets.

@eamexicano
Created September 3, 2012 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eamexicano/3611135 to your computer and use it in GitHub Desktop.
Save eamexicano/3611135 to your computer and use it in GitHub Desktop.
Ejemplo de la etiqueta script utilizada en el encabezado / cuerpo del documento
<!--
Cuando las etiquetas de script están en el cuerpo, el contenido del documento se empieza a visualizar un poco más rápido porque se manda llamar los archivos hasta después de cargar el contenido.
Un ejemplo que detiene la visualización del documento con una alerta de JS.
En realidad no se detiene la visualización pero se tarda un poco más* para mostrar el contenido.
* Dependiendo de otros factores.
Copiar y pegar cada html en un archivo y probar en un navegador.
-->
<!-- script en la cabeza -->
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<style>
body {background: #eee; font-family: sans-serif; margin: 0 auto; width: 800px;}
</style>
<script>
alert('¿ves algo de contenido en el DOM?');
</script>
</head>
<body>
<h1>Encabezado</h1>
<p>El script se encuentra en el encabezado</p>
</body>
</html>
<!-- script en el cuerpo -->
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<style>
body {background: #eee; font-family: sans-serif; margin: 0 auto; width: 800px;}
</style>
</head>
<body>
<h1>Cuerpo</h1>
<p>El script se encuentra en el cuerpo</p>
<script>
alert('¿ves contenido en el DOM?');
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment