# Do Not Preload Audio and Video Files

> Sets audio and video players to preload nothing until the visitor presses play, saving bandwidth on pages with several media files.

- Type: PHP
- Runs: Run everywhere
- Category: [Media](https://wpide.com/library/category/media/)
- Tags: audio, video, performance
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/no-preload-audio-video/

## Code

```php
$wpide_no_preload = function ( $out ) {
    $out['preload'] = 'none';

    return $out;
};

add_filter( 'shortcode_atts_audio', $wpide_no_preload );
add_filter( 'shortcode_atts_video', $wpide_no_preload );

$wpide_no_preload_block = function ( $content ) {
    $content = preg_replace( '/\spreload="[^"]*"/i', '', $content );

    return preg_replace( '/<(audio|video)\b/i', '<$1 preload="none"', $content );
};

add_filter( 'render_block_core/audio', $wpide_no_preload_block );
add_filter( 'render_block_core/video', $wpide_no_preload_block );
```

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Do Not Preload Audio and Video Files" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
