https://github.com/optimizely/amp-js-sdk-poc
https://github.com/optimizely/amp-js-sdk-poc
optimizely-library optimizely-owner-px
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/optimizely/amp-js-sdk-poc
- Owner: optimizely
- Created: 2024-06-07T14:40:01.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-20T14:14:58.000Z (almost 2 years ago)
- Last Synced: 2025-03-08T12:45:59.101Z (over 1 year ago)
- Topics: optimizely-library, optimizely-owner-px
- Language: HTML
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 25
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Optimizely SDK - AMP Page
POC on how to use Optimizely SDK on a AMP page. Here are couple of things to consider
- AMP has a JS file size restriction due to performance reason. So have to use the Lite variant of the JavaScript SDK which excludes the datafile manager and event processor packages. As a result, it is expected that you will provide the datafile manually to the Optimizely SDK either through a local file reference or by using the provided platform-specific `getDatafile()` helper to load in your Optimizely project's datafile. Here are some supported links to get more information-
- [AMP Size Restriction](https://amp.dev/documentation/components/amp-script#restrictions)
- [Optimizely JS - Get started](https://github.com/optimizely/javascript-sdk?tab=readme-ov-file#get-started)
## Build configuration
We have used vite for JS bundling and some preparation purposes. To get the project up and running, do following.
Make changes to `main.ts` or `index.html` if necessary. Then run -
```
# If not already installed
npm install
npm run build
```
## Run
After running the build command, you should see the newly created `dist` directory. Inside that you will find the **AMP valid** HTML document with the custom generated \ tag . You have to serve this dist dirctory with a server to see it live. Now to preview it locally, you can run -
```
npm run preview
```