Support » Plugin: Autoptimize » Lazy Load, NoSniff, Data-Links, and the WordPress Gallery Block

  • First, thanks for an awesome plugin!

    I noticed that a post on one of my client’s sites that contains two images in a WordPress Gallery Block was throwing errors for each image that looked like this:

    The resource from “” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff). the-post

    I was able to duplicate the error on a test site on the same Apache server by creating a post containing a Gallery Block with the same two images. The server is running with:

    Header set X-Content-Type-Options nosniff

    The server isn’t using any caching, but both sites use WP Super Cache in addition to Autoptimize. Clearing the Autoptimize cache and that of WP Super Cache doesn’t prevent the error.

    If I uncheck Lazy Load Images in Autoptimize Settings -> Images, the errors do not appear.

    With Lazy Load enabled, which would ordinarily provoke the error, I can prevent the error by removing the “data-link” attribute from the raw HTML code for the images in the Gallery Block. (The data-link attributes match the resource that’s blocked in the error.)

    The images are still visible, so I’m not sure what effect blocking the data-link is having for end users.

    If I create a gallery using a Classic Block with the same two images, there are no errors, so it’s clearly associated with the Gallery Block and not an issue with the images.

    It should be possible to reproduce the issue on an Apache server that isn’t already running nosniff by adding the following to the .htaccess:

    <IfModule mod_headers.c>
      Header set X-Content-Type-Options nosniff

    Then, you’d just create a post with a Gallery Block and a couple images, with Autoptimize set to lazy load images, and check your browser’s console for the error(s).

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Lazy Load, NoSniff, Data-Links, and the WordPress Gallery Block’ is closed to new replies.