Title: Iframe lazy loading?
Last modified: March 30, 2023

---

# Iframe lazy loading?

 *  Resolved [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * (@ravanh)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/iframe-lazy-loading/)
 * Hi, could it be possible to append an `loading="lazy"` attribute to the iframes
   generated by PDFjs?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Thomas McMahon](https://wordpress.org/support/users/twistermc/)
 * (@twistermc)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/iframe-lazy-loading/#post-16643305)
 * Good idea. I’ll add it to the to do list.
 *  Thread Starter [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * (@ravanh)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/iframe-lazy-loading/#post-16887958)
 * Excellent 🙂
 * In the meantime, I’m using this code snippet as a fix:
 *     ```wp-block-code
       add_filter( 'do_shortcode_tag', function( $output, $tag ) {
       	if ( 'pdfjs-viewer' === $tag ) {
       		$output = str_replace( '></iframe>', ' loading="lazy"></iframe>', $output );
       	}
       	return $output;
       }, 10, 2 );
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Iframe lazy loading?’ is closed to new replies.

 * ![](https://ps.w.org/pdfjs-viewer-shortcode/assets/icon-256x256.png?rev=2301161)
 * [PDF.js Viewer](https://wordpress.org/plugins/pdfjs-viewer-shortcode/)
 * [Support Threads](https://wordpress.org/support/plugin/pdfjs-viewer-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/pdfjs-viewer-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/pdfjs-viewer-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/pdfjs-viewer-shortcode/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * Last activity: [2 years, 11 months ago](https://wordpress.org/support/topic/iframe-lazy-loading/#post-16887958)
 * Status: resolved