ampproject / ampproject/amphtml
I2I: 3p iframe integration splitting by vendor
- Dominant language
- JavaScript
- Stars
- 14.9k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
## Summary
This I2I proposes to split up the third party iframe integration js to multiple by vendor.
## Design document
Currently, we inject a script tag referencing to `f.js` (also being preloaded) within each 3p iframe, containing every 3p integration. This I2I proposes to change it to one file per vendor.
### Bundle size
I have compiled several versions of `f.js` (minimized) to determine the size savings:
1. Present: 197,878 bytes
2. Include only one vendor in [/ads/vendors](https://github.com/ampproject/amphtml/tree/master/ads/vendors): 50,906 bytes
3. Based on 2, only include one vendor config in [_config.js](https://github.com/ampproject/amphtml/blob/master/ads/_config.js): 26,723 bytes
If we combine the two steps above, we will potentially shred 86% dead JS code.
### Implementation
We will create a new build task that generates all the integration JS files, and publish them into a separate folder in each distribution.
### Potential issues
This change will result in more files in each AMP release.
## Motivation
Since the creation of AMP third party iframe integration, [the list of third party vendors](https://github.com/ampproject/amphtml/tree/master/ads/vendors) supporting AMP iframe has grown tremendously. Today, there are close to 300 vendors. It creates problems because all the codes vendors wrote were compiled into a single JS file. Each time the iframe is loaded, the entire JS needs to be loaded, resulting in higher latency and more CPU consumption. This I2I intends to address it by loading only the specific vendor being used.
## Additional context
## Launch tracker
/cc @ampproject/wg-monetization @ampproject/wg-infra
Contributor guide
Assessment
This issue has not been assessed yet.