A partir de Chrome 73, el linkConcepto de Dominio¿Qué es un Enlace?En Internet, un link, además conocido como enlace o hipervínculo, es cualquier texto o imagen que se encuentra en una página web y en la que el usuario puede pulsar o clicar para ser dirigido a otro contenido distinto. Es el principal medio de “desplazamiento” en la red, puesto que se encuentra presente en prácticamente cualquier portal que visites a día de hoy, inclusive en plus rel = «preload» y las imágenes receptivas se pueden combinar para cargar imágenes más rápido.

This article gives me the opportunity to discuss two of my favorite things: responsive images. and preload. As someone who was very involved in the development of both features, I am so excited to see them work together!

Responsive Imaging Overview

Suponga que está navegando por la web en una pantalla de 300 píxeles de ancho y la página solicita una imagen de 1500 píxeles de ancho. Esa página simplemente desperdició muchos de sus datos celulares porque su pantalla no puede hacer nada con toda esa resolución adicional. Idealmente, el browserUn navegador (además: browser) es una herramienta informática que te permite ver documentos y datos y navegar por la red. Los navegadores pueden mostrar distintos tipos de recursos de información; principalmente documentos HTML, a pesar de todo, además son posibles otros tipos de archivos y contenido multimedia, como PDF, JPEG, MPEG, GIF o el lenguaje de meta marcado. A través el uso de complementos especiales y la configuración respectivo, los plus debería obtener una versión de la imagen que sea solo una little más ancho que el tamaño de su pantalla, digamos 325 píxeles. Esto asegura una imagen de alta resolución sin desperdiciar datos. Y, lo que es mejor, la imagen se cargará más rápido. Las imágenes receptivas permiten a los browsersConcepto de Navegadores¿Qué son los Navegadores?Los Navegadores son herramientas informáticas que utilizamos para, normalmente, navegar por Internet y visitar cualquier página web, al mismo tiempo de para hacer otras tareas como ver documentos, observar vídeos o reproducir contenido multimedia de cualquier tipo. Son un tipo de software sencillamente usual y bastante utilizado hoy en día.Insistimos en que es algo que se utiliza con mucha frecuencia, puesto que moverse por Internet plus buscar diferentes recursos de imágenes en diferentes dispositivos. Si no utiliza una CDN de imagen, debe guardar varias dimensiones para cada imagen y especificarlas en el srcset attributeAtributo es una definición que se usa en varios campos de IT. Generalmente, un atributo se usa para describir un fichero o un campo de datos con más detalle. En la programación orientada a objetos, los atributos son una propiedad o característica que se puede asignar a un objeto (elemento). A través el uso de atributos se pueden asignar valores específicos a ciertos items. Áreas de aplicación Las tres áreas plus. los w value tells the browser the width of each version. Depending on the device, the browser can choose the appropriate one:

 

<img src="small.jpg" srcset="small.jpg 500w, medium.jpg 1000w, large.jpg 1500w" alt="">

 

Preload overview

La precarga le permite informar al navegador sobre los recursos críticos que desea cargar lo antes posible, antes de que se detecten en HTMLHTML (Hypertext Markup Language) se usa para estructurar el contenido de texto de un documento web. No sólo se marca el contenido, sino además la meta-información que describe este contenido. Las páginas HTML se almacenan normalmente en el directorio raíz del servidor. Cómo se creó En la era digital, a los usuarios les resulta difícil hallar su camino en las webs y hacer un seguimiento de las estructuras de las plus. Esto es especialmente útil para recursos que no se pueden descubrir fácilmente, como fuentes incluidas en hojas de estilo, imágenes de fondo o recursos cargados desde un script.

 

<link rel="preload" ace="image" href="important.png">

 

Responsive images + preloading = faster image uploads

Responsive images and preloading have been available for the past few years, but at the same time something was missing: there was no way to preload responsive images. Starting in Chrome 73, the browser can preload the correct variant of responsive images specified in srcset before i discover the img label!

Dependiendo de la estructura de su sitio, ¡eso podría significar una visualización de imágenes significativamente más rápida! Realizamos pruebas en un sitio que utiliza JavascriptJavaScript es un lenguaje de programación que funciona en el lado del cliente y con el que las webs pueden ser más funcionales. Incorporación en código HTML El código JavaScript puede ser incrustado en las páginas HTML, para que adquieran funcionalidad. Existen varias opciones. Puede estar entre las etiquetas <SCRIPT> y </SCRIPT>, puede estar contenido en un archivo externo, puede ser un parámetro de las etiquetas HTML, y puede estar plus para cargar imágenes adaptables de forma diferida. La precarga dio como resultado que las imágenes se cargaran 1,2 segundos más rápido.

imagesrcset and imagesizes

To preload responsive images, new attributes were recently added to the element: imagesrcset and imagesizes. They are used with and matches the srcset and sizes syntax used in <img> element.

For example, if you want to preload a responsive image specified with:

 

<img src="wolf.jpg" srcset="wolf_400px.jpg 400w, wolf_800px.jpg 800w, wolf_1600px.jpg 1600w" sizes="50vw" alt="A rad wolf">

 

You can do it by adding the following to your HTML :

 

<link rel="preload" ace="image" href="wolf.jpg" imagesrcset="wolf_400px.jpg 400w, wolf_800px.jpg 800w, wolf_1600px.jpg 1600w" imagesizes="50vw">

 

This starts a request using the same resource selection logic as srcset and sizes will apply.

Use cases

Dynamically Injected Responsive Image Preload

Let's say you are dynamically loading heroic images as part of a slideshow and you know which image will display first. In that case, you probably want to avoid waiting for the script before loading the image in question, as that would delay when users can see it.

You can inspect this problem on a website with a dynamically loaded image gallery:

  1. Opened this sample website in a new tab.
  2. press Control + Shift + J (or Command + Option + J on Mac) to open DevTools.
  3. Click on the Net tongue.
  4. At Constriction drop down list, select Fast 3G.
  5. Turn off the Desactivar el cacheUn caché es un tipo de memoria auxiliar de la que se puede recuperar a alta velocidad con una capacidad de almacenamiento relativamente pequeña. Se encuentra entre la unidad central de procesamiento (CPU) y la memoria principal. Ayuda a evitar el acceso al disco duro o los recálculos complejos almacenando temporalmente ciertos datos y haciéndolos disponibles rápidamente cuando sea necesario. El caché almacena una copia de la petición actual y plus box.
  6. Reload the page.
example-1-before-6341790
This waterfall shows that images only start to load after the browser has finished executing the script, introducing unnecessary delay at the time the image is initially displayed to the user.

Using preload It helps here because the image starts loading early and is likely already there when the browser needs to display it.

example-1-after-5070924
This cascade shows that the first image started loading at the same time as the script, avoiding unnecessary delays and resulting in faster image viewing.

To see the difference preloading makes, you can inspect the same dynamically loaded image gallery but with the first image preloaded following the steps in the first example.

An alternative way to avoid the problem would be to use a brand-based carousel and have the browser preloader collect the necessary resources. However, this approach may not always be practical. (For example, if you are reusing an existing component, which is not brand-based.)

Preloading Background Images with Image Set

Si tiene diferentes imágenes de fondo para diferentes densidades de pantalla, puede especificarlas en su CSSConcepto de CSS¿Qué es el CSS?CSS es un lenguaje de programación que se usa para definir el estilo y el aspecto de un documento que se ha escrito mediante de un lenguaje de etiquetas, como HTML. Conocido además como hojas de estilo en cascada, es el que se emplea para dar colores, indicar tipos de letra o inclusive resaltar aspectos como el espacio entre items para dotar de estilo a plus with the image-set syntax. The browser can then choose which one to display based on the DPR.

 

background-image: image-set( "cat.png" 1x, "cat-2x.png" 2x);

 

The above syntax ignores the fact that vendor prefixes are required for this feature in Chromium and WebKit-based browsers. If you plan to use this feature, you should consider using Autoprefixer to address that automatically.

The problem with CSS background images is that the browser discovers them only after it has downloaded and processed all the CSS on the page. , which can be a lot of CSS ...

You can inspect this problem on a sample website with responsive background image.

example-2-before-6150023
In this example, the image download does not begin until the CSS is completely downloaded, causing unnecessary delay in displaying the image.

Responsive Image Preloading provides a simple, piracy-free way to load those images faster.

 

<link rel=preload href=cat.png ace=image imagesrcset="cat.png 1x, cat-2x.png 2x">

 

You can inspect how the above example behaves with Preloaded customizable background image.

example-2-after-6171228
Here the image and CSS start to download at the same time, avoiding delays and resulting in a faster loading image.

Responsive image preloading in action

Preloading your responsive images can speed them up in theory, but what do you do in practice?

To answer that I created two copies of a PWA demo shop: one that doesn't preload imagesand one that preloads some of them. Since the site lazily loads images with JavaScript, it will likely benefit from preloading the ones that will be in the initial viewport.

That gave me the following results for no preload and to image preload. Looking at the raw numbers, we see that Start Render stayed the same, the speed index improved slightly (273 ms, as the images arrive faster, but they do not occupy a large part of the pixel area), but the actual metric that captures the difference is the Last painted hero metric, which improved by 1.2 seconds. 🎉🎉

Of course, nothing captures the visual difference like a filmstrip comparison:

example-3-3734804
The filmstrip shows that images arrive significantly faster when preloaded, resulting in a vastly improved user experience.

Preload and ?

If you are familiar with receptive images, you may be wondering 'What about ? «.

El Web PerformanceEn el caso de las webs, el término Performance o rendimiento, se refiere a la velocidad de carga o a la potencia de cálculo de un servidor, es decir, a la velocidad a la que se transmiten los datos del servidor al cliente. Razones para una buena performance Una web que se carga lentamente, puede animar a los clientes potenciales a abandonar la página. Para asegurar una interacción fluida, se tiene plus Working Group está hablando de agregar un equivalente de precarga para srcset and sizes, but not the element, which addresses the "art direction" use case.

Why is this use case "neglected"?

While there is interest in solving that use case as well, there are still a number of technical problems to solve which means that a solution here would have significant complexity. On top of that, it seems like for the most part the use case can be addressed today, even if in a hacky way (see below).

Given that, Web Performance WG decided to send srcset first and see if the demand for equivalent picture support arises.

If you are in pre-charge condition you may be able to use the following technique as a solution.

Given the following scenario:

 

<picture>
<source src="small_cat.jpg" half="(max-width: 400px)">
<source src="medium_cat.jpg" half="(max-width: 800px)">
<img src="huge_cat.jpg">
</picture>

 

the Element logic (or image source selection logic, to be precise), would be to go over the half attributes of the items in order, find the first one that matches and use the attached resource.

Because receptive preloading has no notion of "order" or "first match", breakpoints should be translated into something like:

 

<link rel="preload" href="small_cat.jpg" ace="image" half="(max-width: 400px)">
<link rel="preload" href="medium_cat.jpg" ace="image" half="(min-width: 400.1px) and (max-width: 800px)">
<link rel="preload" href="large_cat.jpg" ace="image" half="(min-width: 800.1px)">

 

Summary

Responsive image preloading gives us exciting new possibilities to preload responsive images in ways previously only possible through hacks. It's an important new addition to the speed-conscious developer's toolbox and allows us to make sure that the important images we want to show our users as soon as possible will be there when we need them.