Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable authors to specify SXG-only tags #87

Open
twifkak opened this issue Oct 8, 2021 · 4 comments
Open

Enable authors to specify SXG-only tags #87

twifkak opened this issue Oct 8, 2021 · 4 comments
Milestone

Comments

@twifkak
Copy link
Collaborator

twifkak commented Oct 8, 2021

For instance if the HTML contains:

<template data-sxg-only>
  <script>log("visit-from-sxg=true")</script>
</template>

then when generating an SXG, rewrite it to:

<script>log("visit-from-sxg=true")</script>

Other possible spellings include <template class=sxg-only> or <script type=text/sxg-only> or <!--[if SXG]>, but the above seems the most general and least likely to collide with existing pages. (But that should be confirmed before implementing.)

Motivation

Enable web publishers to distinguish SXG visits from unsigned visits in their analytics. This could help them track overall usage, or compare performance metrics between the two cohorts. Examples of feature requests for a similar tool (CF ASX):

@twifkak
Copy link
Collaborator Author

twifkak commented Oct 13, 2021

and/or we could have a simpler API for the common use case. Something like:

<meta name=declare-sxg-var>

becomes something like:

<script>window.isSXG = true</script>

@twifkak
Copy link
Collaborator Author

twifkak commented Oct 19, 2021

On further thought, we should definitely at least do the first one (probably both). And it should delete the template tag on non-SXG.

This covers another use case: being able to include JS & templates (they can be nested) for lazy-loading personalized elements, without affecting the byte size of the non-SXG version (which can personalize via dynamic HTML instead).

@twifkak twifkak added this to the v2 milestone Oct 20, 2021
@twifkak twifkak self-assigned this Oct 20, 2021
This was referenced Oct 21, 2021
@twifkak
Copy link
Collaborator Author

twifkak commented Oct 23, 2021

Remaining task is to implement on fastly_compute.

@twifkak
Copy link
Collaborator Author

twifkak commented May 13, 2022

Implementing for fastly_compute should be easy now that process_html.rs exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant