Skip to content

First pass adding pure PWA#7963

Closed
gravityrail wants to merge 86 commits intomasterfrom
add/pwa
Closed

First pass adding pure PWA#7963
gravityrail wants to merge 86 commits intomasterfrom
add/pwa

Conversation

@gravityrail
Copy link
Copy Markdown
Contributor

Adds some basic PWA features:

  • cache all non-WP-Admin responses retrieved via GET
  • add manifest for pseudo-app-install and splash screen support
  • detect theme colors
  • Official AMP plugin integration

@gravityrail gravityrail requested a review from a team as a code owner October 10, 2017 18:03
@gravityrail gravityrail self-assigned this Oct 10, 2017
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor drive-by nitpick. This, and the other files below, don't end with an empty newline.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks. Will push up this change soon.

@ebinnion ebinnion added this to the 5.5 milestone Oct 10, 2017
@jeherve
Copy link
Copy Markdown
Member

jeherve commented Oct 11, 2017

Do you think you could add some screenshots and some testing instructions so we all know what to look for?

Thanks!

@jeherve jeherve added PWA and removed [Feature] Mobile Theme aka minileven labels Oct 11, 2017
Copy link
Copy Markdown
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few questions as I'm not really familiar with what the module really does just yet.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this play with other AMP plugins like our own? Shouldn't we not output anything when that plugin is active?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amp_post_template_head is an action fired by our AMP plugin. AMP needs a specific manifest format that is not regular HTML. This feature is designed to work with the official AMP plugin, not replace it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this work on sites that do not have an active SSL certificate?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't work at all on those sites.

@gravityrail gravityrail added [Status] In Progress and removed [Status] Needs Review This PR is ready for review. labels Oct 11, 2017
@gravityrail
Copy link
Copy Markdown
Contributor Author

Do you think you could add some screenshots and some testing instructions so we all know what to look for?

I will soon! This is still a work in progress.

'jp_group' => 'pwa',
),
'pwa_lazy_images' => array(
'description' => esc_html__( 'Display notice on page when the browser is offline', 'jetpack' ),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dupe of the above label :)

return cache.match( request )
.then( function( response ) {
// only do more work if we don't already have a response
if ( response ) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the invalidation process? If visitor caches content and site owner updates the resource.. Unlike the "regular" HTTP cache, resources in SW cache are not automatically checked for freshness and have to be manually (re+in)validated by our code here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added stale-while-revalidate in the latest couple of commits. I'm not actually taking over the browser and replacing content yet, that's next...

return isset( $registration->extra['jetpack-inline'] ) && $registration->extra['jetpack-inline'];
}

private function should_remove_style( $handle ) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For locally defined (inlined fonts), a better solution might be to inject a font-display [1] swap? For external resources, like Typekit and Google Fonts, that won't work today, but hopefully soon, once implementations for [2] land in Chrome and other browsers.
Alternatively, have you considered non-blocking font load / loadCSS [3] variant instead? That introduces FOUT, but I still think it's better than omitting them entirely?


[1] https://www.w3.org/TR/css-fonts-4/#font-display-desc
[2] https://www.w3.org/TR/css-fonts-4/#font-display-font-feature-values
[3] https://github.com/filamentgroup/loadCSS#recommended-loadcss-usage

@jeherve jeherve removed this from the 5.5 milestone Oct 20, 2017
@caraya
Copy link
Copy Markdown

caraya commented Nov 9, 2017

Is there any particular reason for using protocol relative and not HTTPS URLs when connecting to CDNs? There is no reason not to make the CDN URL an HTTPS one

@gravityrail gravityrail mentioned this pull request Nov 22, 2017
@jeherve jeherve mentioned this pull request Dec 8, 2017
}

private function get_service_worker_url() {
return add_query_arg( PWA_SW_QUERY_VAR, '1', trailingslashit( site_url() ) . 'index.php' );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If pretty permalinks are enabled, shouldn't this return home_url( '/service-worker.js' ) as the rewrite rule was added in the register_rewrite_rule method?

@dereksmart
Copy link
Copy Markdown
Contributor

@gravityrail can this be closed?

@gravityrail gravityrail deleted the add/pwa branch June 20, 2018 22:47
@gravityrail gravityrail restored the add/pwa branch January 28, 2020 20:49
@kraftbj kraftbj deleted the add/pwa branch January 4, 2021 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.