Skip to content

Commit

Permalink
Merge pull request #33 from humanmade/enqueue-in-header
Browse files Browse the repository at this point in the history
Allow the option to enqueue script in the header
  • Loading branch information
kadamwhite authored Jan 27, 2021
2 parents 2aa60d1 + cc7ef98 commit 4753d37
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ To register an asset to be manually enqueued later, use `Asset_Loader\register_a

If a manifest is not present then `Asset_Loader` will attempt to load the specified resource from the same directory containing the manifest file.

By default, all enqueues will be added at the end of the page, in the `wp_footer` action. If you need your script to be enqueued in the document `<head>`, pass the flag `'in-footer' => false,` within the options array.

## Local Development

Before submitting a pull request, ensure that your PHP code passes all existing unit tests and conforms to our [coding standards](https://github.com/humanmade/coding-standards) by running these commands:
Expand Down
3 changes: 2 additions & 1 deletion inc/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ function _register_or_update_script( string $handle, string $asset_uri, array $d
function register_asset( string $manifest_path, string $target_asset, array $options = [] ) : array {
$defaults = [
'dependencies' => [],
'in-footer' => true,
];
$options = wp_parse_args( $options, $defaults );

Expand Down Expand Up @@ -396,7 +397,7 @@ function register_asset( string $manifest_path, string $target_asset, array $opt
$asset_uri,
$options['dependencies'],
$asset_version,
true
$options['in-footer']
);
$handles['script'] = $asset_handle;
}
Expand Down

0 comments on commit 4753d37

Please sign in to comment.