Async vs Defer: cuándo usar uno u otro

Aprende a usar defer y async para optimizar la carga de JavaScript, mejorar Core Web Vitals y SEO, y aplicar buenas prácticas de rendimiento web con Q2BSTUDIO.

9 sept 2025 • 2 min read • Q2BSTUDIO Team

Inteligencia-Artificial-

Uno de los motivos más comunes por los que una página web carga despacio es el manejo de los archivos JavaScript. Por defecto, cuando el navegador encuentra una etiqueta <script> detiene el parseo del HTML, descarga el archivo, lo valida y lo ejecuta antes de continuar. Ese comportamiento puede penalizar los Core Web Vitals y afectar la SEO y la experiencia de usuario.

Para controlar ese flujo existen dos atributos muy útiles: defer y async. Usar cada uno correctamente mejora tiempos de carga sin sacrificar funcionalidad ni posicionamiento.

Defer: si añades el atributo defer a un script como <script src=script.js defer></script> el navegador inicia la descarga del archivo en paralelo y sigue procesando el HTML. La ejecución del script se pospone hasta que todo el HTML ha sido parseado y se respetará el orden en que declaran los scripts. Defer es la opción recomendada para scripts que enriquecen la interfaz, como carruseles, componentes interactivos o animaciones, es decir para la mayoría de los scripts no críticos.

Async: colocando async como en <script src=script.js async></script> el archivo también se descarga en paralelo pero se ejecuta inmediatamente cuando termina la descarga, interrumpiendo el parseo del HTML. Los scripts async no respetan el orden de declaración sino el de descarga, por lo que son adecuados para bloques independientes como etiquetas de analítica o herramientas de seguimiento.

Cuándo no usar ninguno de los dos: hay scripts que deben ser bloqueantes porque son imprescindibles para el funcionamiento de la página, por ejemplo el framework principal de una SPA, plantillas que generan contenido dinámico en el cliente o scripts que gestionan procesos críticos de eCommerce como el checkout. En esos casos es correcto mantener el comportamiento por defecto.

Buenas prácticas rápidas: prioriza defer para scripts UI, usa async para recursos independientes, coloca scripts no críticos al final del body o usa carga condicional, comprime y concatena cuando sea posible, y prueba siempre el sitio tras cambiar atributos para evitar roturas.

En Q2BSTUDIO ayudamos a optimizar tanto la arquitectura frontend como backend para conseguir mejores tiempos de carga y una experiencia de usuario superior. Si necesitas desarrollar aplicaciones a medida o software a medida con una optimización desde el diseño hasta la puesta en producción visita nuestra sección de desarrollo de aplicaciones y software a medida y descubre cómo integramos buenas prácticas de rendimiento.

Además, en Q2BSTUDIO somos especialistas en inteligencia artificial, ia para empresas y agentes IA, ciberseguridad, servicios cloud aws y azure y servicios inteligencia de negocio como power bi. Si te interesa modernizar tu plataforma con soluciones seguras y escalables y sacar partido del dato con Power BI y modelos de IA consulta nuestra página de inteligencia artificial para empresas para ver casos y servicios.

Aplicar defer o async correctamente es una palanca sencilla para mejorar velocidad, Core Web Vitals y SEO; si no estás seguro de cómo hacerlo en tus proyectos, Q2BSTUDIO puede auditar tu código, implementar correcciones y desplegar soluciones completas que incluyan ciberseguridad, cloud y business intelligence.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Artificial intelligence

AI agents, chatbots, and intelligent assistants that automate tasks and serve your customers 24/7 to improve the efficiency of your business.

More info

Software Development

Web, mobile, and desktop applications, intranets, e-commerce, SaaS, and management platforms designed for your company's specific needs.

More info

Cloud services

Migration, infrastructure, managed hosting, high availability, and security on Microsoft Azure and Amazon Web Services to help your business scale without limits.

More info

Cybersecurity and pentesting

Security audits, penetration testing and protection of applications, data and infrastructure on-premise and cloud, with ethical hacking and regulatory compliance.

More info

Business Intelligence

Dashboards and data analysis with Power BI: we integrate your sources, design dashboards and KPIs and turn your data into decisions.

More info

Process automation

We automate repetitive tasks and connect your applications with n8n, Power Automate, Make, and RPA, eliminating manual work and increasing productivity.

More info

Training for Companies

We train your teams in technology with criteria: web development, databases, Git, best practices and security, automation with n8n, artificial intelligence for companies and creation of AI solutions with Azure AI Foundry.

More info

Code Auditing

We audit the code that you, your team or an AI create: we tell you what is good and what to improve, we secure it and make it ready for production, web or app.

More info

AI Image Generation

We create for you the images that your business needs with artificial intelligence: product, networks, advertising, illustration and avatars. You tell us what you want and we deliver it ready to use.

More info

AI Video Generation

We create videos with artificial intelligence for you: promotional, networking, virtual presenters, dubbing and animations. You tell us the idea and we will deliver it assembled and ready to publish.

More info

AI Conversational Avatars

We create conversational avatars with AI – digital humans with a face and voice – that serve your customers and teams with the knowledge of your company, on your website, interactive monitors, WhatsApp or Teams.

More info

Online Marketing and AI

Google Ads, Meta Ads, LinkedIn Ads and AI Engine Positioning (GEO/AEO): we attract customers and make your brand appear where they search for you, also on ChatGPT, Gemini and Perplexity.

More info

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.

Live Chat