chriskyfung / amp-affiliately-jekyll-theme

An AMP-Ready Jekyll Blog Theme
https://chriskyfung.github.io/amp-affiliately-jekyll-theme/
MIT License
19 stars 12 forks source link

šŸš‘ Fix (AMP): incorrect usage of `data-ampdevmode` attribute on non-dev `<amp-script>` element #58

Closed chriskyfung closed 7 months ago

chriskyfung commented 7 months ago

Description

The data-ampdevmode attribute is being used on an <amp-script> tag in production code, which can lead to unintended behavior, such as:

Steps to Reproduce

  1. Create an AMP page that includes the following code:
<amp-script src="https://example.com/script.js" data-ampdevmode></amp-script>
  1. Publish the page and load it in a browser.

  2. Inspect the network requests and observe that the script is being loaded from the development server instead of the production server.

Expected Behavior

The data-ampdevmode attribute should only be used in development environments and not in production. A script hash should be used to verify that the custom script and included in a meta[name=amp-script-src] element in the document head.

Actual Behavior

The amp-script does not run in production because the data-ampdevmode attribute is present.

Proposed Fix

Remove the data-ampdevmode attribute from the <amp-script> component in production environment.