• Resolved supraniti

    (@supraniti)


    On a fresh wp install, after installing the pwa plugin,
    and in order to integrate my own code into the service worker –
    i have added the following code into my plugin file:

    // Add service worker script
    function register_fc_service_worker_script( $scripts ) {
    	$scripts->register(
    		'fcsw', // Handle.
    		array(
    			'src'  => plugin_dir_url( __FILE__ ) . 'fcsw.js', // Source.
    			'deps' => array( 'app-shell' ), // Dependency.
    		)
    	);
    }
    // Register for both the frontend and admin service worker.
    add_action( 'wp_front_service_worker', 'register_fc_service_worker_script' );
    add_action( 'wp_admin_service_worker', 'register_fc_service_worker_script' );

    the script file consists of the following line:
    console.log('hello from some context',this);

    the result:
    service worker is up and running, but no log on console.
    in addition i was looking for my script code inside the sw code – it doesn’t exist.

Viewing 1 replies (of 1 total)
  • Plugin Author Weston Ruter

    (@westonruter)

    Ah, because the app-shell here is just an example handle. It’s not something that actually exists. So just remove 'deps' => array( 'app-shell' ), // Dependency.

Viewing 1 replies (of 1 total)

The topic ‘service worker script registration doesn’t seem to work’ is closed to new replies.