# Move Selected Scripts to the Footer

> Moves the scripts you list from the page head to the footer, so they stop blocking the page from rendering.

- Type: PHP
- Runs: Frontend only
- Category: [Performance](https://wpide.com/library/category/performance/)
- Tags: performance, javascript, render-blocking
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/move-scripts-to-footer/

## Code

```php
// Script handles to print in the footer. Find handles in the page source: id="HANDLE-js".
$wpide_footer_scripts = array( 'some-slider', 'some-plugin-frontend' );

add_action( 'wp_enqueue_scripts', function () use ( $wpide_footer_scripts ) {
    $scripts = wp_scripts();

    foreach ( $wpide_footer_scripts as $handle ) {
        if ( isset( $scripts->registered[ $handle ] ) ) {
            $scripts->add_data( $handle, 'group', 1 );
        }
    }
}, 999 );
```

## Notes

A script stays in the head if another head script depends on it, so test interactive features afterwards.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Move Selected Scripts to the Footer" 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/
