Skip to content

Workbox window script module should be printed with wp_print_inline_script_tag() #1240

Description

@westonruter

Given this code here:

<script type="module">
import { Workbox } from <?php echo wp_json_encode( $workbox_window_src ); ?>;
if ( 'serviceWorker' in navigator ) {
window.wp = window.wp || {};
window.wp.serviceWorkerWindow = new Workbox(
<?php echo wp_json_encode( $sw_src ); ?>,
<?php echo wp_json_encode( $register_options ); ?>
);
window.wp.serviceWorkerWindow.register();
}
</script>

The lack of wp_print_inline_script_tag() means that CSP nonce attribute cannot be injected.

Related: #1241

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions