Search code examples
amp-htmlaccelerated-mobile-page

Does the sequence of including the components files matter?


for some reason the amp component amp-lightbox does not work when i do not regard the sequence of the included amp-components.

unrecognized AMP element: Did you forget to include it via <script.....

Of course i didn't forget to include it, but as far I switch the order of the include files, then it works.

Not working:

<script async custom-element="amp-list" src="https://cdn.ampproject.org/v0/amp-list-0.1.js"></script>    
<script async custom-element="amp-lightbox" src="https://cdn.ampproject.org/v0/amp-lightbox-0.1.js"></script>

and working example:

<script async custom-element="amp-lightbox" src="https://cdn.ampproject.org/v0/amp-lightbox-0.1.js"></script>    
<script async custom-element="amp-list" src="https://cdn.ampproject.org/v0/amp-list-0.1.js"></script>

I am also not using amp-list in conjuction with amp-lightbox...


Solution

  • Since the async attribute is used, the order shouldn't matter. Each script will execute as soon as it finishes downloading, regardless of the order it appears in. Not an AMP tagged question, but this one has some very good additional explanations regarding it.