Google AMP – Basic Syntax ”; Previous Next In this chapter, we will discuss the basic requirements to get started with Google AMP pages. Sample Amp Page A basic example for an amp page is shown below − <!doctype html> <html amp> <head> <meta charset = “utf-8”> <title>Amp Sample Page</title> <link rel = “canonical” href = “./regular-html-version.html”> <meta name = “viewport” content = “width = device-width, minimum-scale = 1,initial-scale = 1”> <style amp-custom> h1 {color: red} </style> <style amp-boilerplate> body{ -webkit-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation: -amp-start 8s steps(1,end) 0s 1 normal both;animation: -amp-start 8s steps(1,end) 0s 1 normal both } @-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}} </style> <noscript> <style amp-boilerplate> body{ -webkit-animation:none; -moz-animation:none; -ms-animation:none; animation:none} </style> </noscript> <script async src = “https://cdn.ampproject.org/v0.js”> </script> </head> <body> <h1>Amp Sample Page</h1> <p> <amp-img src = “images/christmas1.jpg” width = “300” height = “300” layout = “responsive”> </amp-img> </p> </body> </html> Mandatory Tags There are some mandatory tags to be included in a amp page. This section discusses them in detail − We have to make sure that we add amp or ⚡ to the html tag as shown below <html amp> OR <html ⚡> We should add the <head> and <body> tags to the html page. Amp validation may fail if you miss any of the mandatory meta tags. Some mandatory mets tags that are to be added head section of the page are shown here − <meta charset=”utf-8″> <meta name = “viewport” content = “width = device-width, minimum-scale = 1, initial-scale = 1″> Link of rel=”canonical” to be added inside head tag <link rel = “canonical” href = “./regular-html-version.html”> Style tag with amp-boilerplate − <style amp-boilerplate> body{ -webkit-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation: -amp-start 8s steps(1,end) 0s 1 normal both;animation: -amp-start 8s steps(1,end) 0s 1 normal both } @-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}} </style> Noscript tag with amp-boilerplate − <noscript> <style amp-boilerplate> body{ -webkit-animation:none; -moz-animation:none; -ms-animation:none; animation:none} </style> </noscript> The amp script tag with async added to it as shown below. This is the most important tag of all − <script async src = “https://cdn.ampproject.org/v0.js”> </script> You should use this tag incase you want to add custom css to the page. Please make a note here we cannot call external style sheet in amp pages. To add custom css, all your css has to go here − <style amp-custom> //all your styles here </style> You can validate the above page in your browser using #developement=1 at the end of the page-url. Now, let us test the same in the browser. I have hosted the page locally and saved it as amppage.html. The url for above to be tested is http://localhost/googleamp/amppage.html#development=1 Example <!doctype html> <html amp> <head> <meta charset = “utf-8”> <title>Amp Sample Page</title> <link rel = “canonical” href = “./regular-html-version.html”> <meta name = “viewport” content = “width=device-width, minimum-scale = 1,initial-scale = 1”> <style amp-custom> h1 {color: red} </style> <style amp-boilerplate> body{ -webkit-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation: -amp-start 8s steps(1,end) 0s 1 normal both;animation: -amp-start 8s steps(1,end) 0s 1 normal both } @-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}} </style> <noscript> <style amp-boilerplate> body{ -webkit-animation:none; -moz-animation:none; -ms-animation:none; animation:none} </style> </noscript> <script async src = “https://cdn.ampproject.org/v0.js”> </script> </head> <body> <h1>Amp Sample Page</h1> <p> <amp-img src = “images/christmas1.jpg” width = “300” height = “250” layout = “responsive”> </amp-img> </p> </body> </html> Output You can see the amp validation status in the developer console as follows − It gives us AMP validation successful as we have added all the required mandatory tags for a valid amp page. Print Page Previous Next Advertisements ”;
Category: google Amp
Google AMP – Layout
Google AMP – Layout ”; Previous Next AMP-Layout is one of the important feature available in Google-amp. Amp Layout makes sure the amp components are rendered properly when the page is loaded without causing any flicker or scrolling issue. Google AMP make sure that layout rendering is done on the page before any other remote resources like http request for images, data calls are done. The list of layout attributes is given below. width and height layout sizes heights media placeholder fallback noloading We will consider the layout attribute in detail in this chapter. The rest attributes are discussed in details in the chapter − Google AMP – Attributes of this tutorial. Layout Attribute We can use layout attribute on an amp-component which will decide how the component will render inside the page. A list of layouts supported by amp is given below − Not Present Container fill fixed fixed-height flex-item intrinsic nodisplay Responsive For each of this layout, we will see a working example which will show how the layout attribute renders the amp-component differently. We will make use of amp-img component in our examples. Not Present Example <!doctype html> <html amp lang = “en”> <head> <meta charset = “utf-8″> <script async src=”https://cdn.ampproject.org/v0.js”></script> <title>Google AMP – Image</title> <link rel = “canonical” href = “http://example.ampproject.org/article-metadata.html”> <meta name = “viewport” content = “width = device-width, minimum-scale = 1,initial-scale = 1”> <style amp-boilerplate> body{ -webkit-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation: -amp-start 8s steps(1,end) 0s 1 normal both;animation: -amp-start 8s steps(1,end) 0s 1 normal both } @-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}} </style> <noscript> <style amp-boilerplate> body{ -webkit-animation:none; -moz-animation:none; -ms-animation:none; animation:none } </style> </noscript> <style amp-custom> amp-img { border: 1px solid black; border-radius: 4px; padding: 5px; } </style> </head> <body> <h1>Google AMP – Image Example</h1> <amp-img alt = “Beautiful Flower”src = “images/flower.jpg” width = “246” height = “205”> </amp-img> </body> </html> Output Container Example Layout=”container” is mostly given to the parent element and the child element takes the sizes defined. <!doctype html> <html amp lang = “en”> <head> <meta charset = “utf-8”> <script async src = “https://cdn.ampproject.org/v0.js”></script> <title>Google AMP – Image</title> <link rel = “canonical” href = “http://example.ampproject.org/article-metadata.html”> <meta name = “viewport” content = “width = device-width, minimum-scale = 1,initial-scale = 1”> <style amp-boilerplate> body{ -webkit-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation: -amp-start 8s steps(1,end) 0s 1 normal both;animation: -amp-start 8s steps(1,end) 0s 1 normal both }@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}} </style> <noscript> <style amp-boilerplate> body{ -webkit-animation:none; -moz-animation:none; -ms-animation:none; animation:none } </style> </noscript> <style amp-custom> amp-img { border: 1px solid black; border-radius: 4px; padding: 5px; } h1{ font-family: “Segoe UI”,Arial,sans-serif; font-weight: 400;margin: 10px 0; } </style> </head> <body> <h1>Google AMP – Layout = container Image Example</h1> <amp-accordion layout = “container”> <amp-img alt = “Beautiful Flower” src = “images/flower.jpg” width = “246” height = “205”> </amp-img> </amp-accordion> </body> </html> Output Fill Example Layout= ”fill” takes the width and height of the parent element. <!doctype html> <html amp lang = “en”> <head> <meta charset = “utf-8”> <script async src = “https://cdn.ampproject.org/v0.js”></script> <title> Google AMP – Image <title> <link rel = “canonical” href = “http://example.ampproject.org/article-metadata.html”> <meta name = “viewport” content = “width = device-width, minimum-scale = 1,initial-scale = 1”> <style amp-boilerplate> body{ -webkit-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation: -amp-start 8s steps(1,end) 0s 1 normal both;animation: -amp-start 8s steps(1,end) 0s 1 normal both } @-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}} </style> <noscript> <style amp-boilerplate> body{ -webkit-animation:none; -moz-animation:none; -ms-animation:none; animation:none } </style> </noscript> <style amp-custom> amp-img { border: 1px solid black; border-radius: 4px; padding: 5px; } h1{font-family: “Segoe UI”,Arial,sans-serif; font-weight: 400;margin: 10px 0;} </style> </head> <body> <h1>Google AMP – Layout = fill Image Example</h1> <div style = “position:relative;width:100px;height:100px;”> <amp-img alt = “Beautiful Flower” src = “images/flower.jpg” width = “246” height = “205” layout = “fill”> </amp-img> </div> </body> </html> Output Fixed and fixed-height Example Before understanding the usage of fixed and fixed-height, please note the following two points − layout=”fixed” needs to have width and height and the amp-component will be shown in that. layout=”fixed-height” needs to have height specified for the component.It will make sure the height is not changed .The width must not be specified when using fixed-height or it can be auto. <!doctype html> <html amp lang = “en”> <head> <meta charset = “utf-8”> <script async src = “https://cdn.ampproject.org/v0.js”></script> <title>Google AMP – Image</title> <link rel = “canonical” href = “http://example.ampproject.org/article-metadata.html”> <meta name = “viewport” content = “width = device-width, minimum-scale = 1,initial-scale = 1”> <style amp-boilerplate> body{ -webkit-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation: -amp-start 8s steps(1,end) 0s 1 normal both;animation: -amp-start 8s steps(1,end) 0s 1 normal both } @-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}} </style> <noscript> <style amp-boilerplate> body{ -webkit-animation:none; -moz-animation:none; -ms-animation:none; animation:none } </style> </noscript> <style amp-custom> amp-img { border: 1px solid black; border-radius: 4px; padding: 5px; } div{ display: inline-block; width: 200px; height:200px; margin: 5px; } h1{font-family: “Segoe UI”,Arial,sans-serif; font-weight: 400;margin: 10px 0;} </style> </head> <body> <h1>Google AMP – Layout = fixed and Layout = fixed-height Image Example </h1> <div> <amp-img alt = “Beautiful Flower” src = “images/flower.jpg” width = “246” height = “205” layout = “fixed”> </amp-img> </div> <div> <amp-img alt = “Beautiful Flower” src = “images/flower.jpg” height = “205” layout = “fixed-height”> </amp-img> </div> </body> </html> Output Flex-item and intrinsic <!doctype html> <html amp lang = “en”> <head> <meta charset = “utf-8″> <script async src =”https://cdn.ampproject.org/v0.js”></script> <title>Google AMP – Image</title> <link rel = “canonical” href =” http://example.ampproject.org/article-metadata.html”> <meta name = “viewport” content = “width = device-width, minimum-scale = 1,initial-scale = 1”> <style amp-boilerplate> body{ -webkit-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation: -amp-start 8s steps(1,end) 0s 1 normal both;animation: -amp-start 8s steps(1,end) 0s 1 normal both } @-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible <style> <noscript> <style amp-boilerplate> body{ -webkit-animation:none; -moz-animation:none; -ms-animation:none; animation:none } </style> </noscript> <style amp-custom> amp-img { border: 1px solid black; border-radius:
Google AMP – Custom Javascript ”; Previous Next In the previous chapters, we have studied many amp-components. We have also seen that for each component to work we need add a javascript file. For example, for amp-iframe the script added is as follows − <script async custom-element=”amp-iframe” src=”https://cdn.ampproject.org/v0/amp-iframe-0.1.js”> </script> We have async added to the script tag. This is the standard for amp as they load all the javascript files asynchronously. There is a custom-element attribute added which has the name of the component it is used for. To use any amp-component if it is not a part of the core amp javascript file, the script has to be added as shown above. We are mostly used to writing, a lot of javascript code inside pages and also include javascript file using script tag. How can we do that in amp? So for that AMP does not allow any script code to be written or load script tag externally. Amp has its own component to take care of the job which is suppose to be done by the additional script which is added on the page. This is basically done for performance reasons, to load the page content faster and not have javascript delay the rendering or do any changes to the DOM. This is the specification given by AMP as per their official site for script tags − Prohibited unless the type is application/ld+json. (Other non-executable values may be added as needed.) Exception is the mandatory script tag to load the AMP runtime and the script tags to load extended components. A working example where we can use application/ld+json inside our amp pages is shown here. Note that we are using the script tag with type=”application/ld+json” for amp-analytics component to fire tracker. Similarly, we can use script tag with type=”application/ld+json” on other amp-components wherever required. Example <!doctype html> <html amp> <head> <meta charset = “utf-8”> <title>amp-analytics</title> <script async src = “https://cdn.ampproject.org/v0.js”> </script> <script async custom-element = “amp-analytics” src = “https://cdn.ampproject.org/v0/amp-analytics-0.1.js”> </script> <link rel = “canonical” href = “ampanalytics.html”> <meta name = “viewport” content = “width=device-width, minimum-scale = 1,initial-scale = 1”> <style amp-boilerplate> body{ -webkit-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation: -amp-start 8s steps(1,end) 0s 1 normal both;animation: -amp-start 8s steps(1,end) 0s 1 normal both } @-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}} </style> <noscript> <style amp-boilerplate> body{ -webkit-animation:none; -moz-animation:none; -ms-animation:none; animation:none} </style> </noscript> </head> <body> <h1>Google Amp – Analytics</h1> <amp-analytics> <script type = “application/json”> { “requests”: { “event”: “http://localhost:8080/googleamp/tracking.php? user=test&account=localhost&event=${eventId}” }, “triggers”: { “trackPageview”: { “on”: “visible”, “request”: “event”, “vars”: { “eventId”: “pageview” } } } } </script> </amp-analytics> </body> </html> When the page is hit in the browser, the tracker will be fired for pageview. It can be seen in the Google network tab as shown below. Print Page Previous Next Advertisements ”;
Google AMP – Link
Google AMP – Link ”; Previous Next The Link tag in amp is used to tell the Google search engine about the amp and non-amp pages available. In this chapter, let us discuss in detail the aspects involved with Link tag and how google decides about the amp-page and non amp-page. AMP Page Discovery Consider you have a site called www.mypage.com. The news article links to the page − www.mypage.com/news/myfirstnews.html. When a user searches in the Google search engine and happens to get the non amp-page, in order to also get reference to the amp page, we need to specify the amp url using the link tag as shown below − Example Page-url for Non amp-page <link rel = “amphtml” href = “https://www.mypage.com/news/amp/myfirstnews_amp.html”> Here rel= ”amphtml” is specified for a non amp page to point to the amp version, so that Google shows the right one based on platform Page-url for amp-page <link rel = “canonical” href = “https://www.mypage.com/news/myfirstnews.html”> Here rel=”canonical” is specified in amp page to point to the standard version of html, so that Google shows the right one based on platform. Incase your site has only one page, which is an amp page, you should still not forget to add the rel=”canonical” which will point to itself − <link rel = “canonical” href = “https://www.mypage.com/news/amp/myfirstnews_amp.html”> The following diagram shows a reference to rel=”amphtml” pointing to amp page and rel=”canonical” pointing to standard html page. Fonts Using Link Fonts can be loaded externally using link as shown below − <link rel = “stylesheet” href = “https://fonts.googleapis.com/css?family=Roboto”> Note that only whitelisted origins are allowed. The list of whitelisted origin where we can get the fonts is as shown here − Fonts.com − https://fast.fonts.net Google Fonts − https://fonts.googleapis.com Font Awesome − https://maxcdn.bootstrapcdn.com Typekit − https://use.typekit.net/kitId.css (replace kitId accordingly) A working example using rel=”canonical” and rel=”stylesheet” is shown below − Example <!doctype html> <html amp> <head> <meta charset =”utf-8″> <title>Amp Sample Page</title> <link rel = “canonical” href = “amppage.html”> <meta name = “viewport” content = “width = device-width,minimum-scale=1,initial-scale = 1”> <style amp-custom> h1 {color: red} </style> <style amp-boilerplate> body{ -webkit-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation: -amp-start 8s steps(1,end) 0s 1 normal both;animation: -amp-start 8s steps(1,end) 0s 1 normal both } @-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}} </style> <noscript> <style amp-boilerplate> body{ -webkit-animation:none; -moz-animation:none; -ms-animation:none; animation:none } </style> </noscript> <script async src = “https://cdn.ampproject.org/v0.js”></script> <link rel = “stylesheet” href = “https://fonts.googleapis.com/css?family=Roboto”> </head> <body> <h1>Amp Sample Page</h1> <p> <amp-img src = “images/christmas1.jpg” width = “300” height = “250” layout = “responsive”> </amp-img> </p> <p style = “font-family: ”Roboto”; font-size:25px;”> Welcome to Amp Page </p> </body> </html> Output The output of the code shown above is as shown below − Print Page Previous Next Advertisements ”;
Google AMP – Images
Google AMP – Images ”; Previous Next Images used in Google AMP page is similar to how it is used in a standard html page, but only difference is the way the tag name is used with some additional properties. This chapter discusses these in detail. Observe the syntaxes shown below − Standard HTML <img src = ”example.jpg” width = ”300” height = ”250” alt = ”Example” ></img> In AMP page <amp-img src = “example.jpg” alt = “Example” height = “300” width = “250” ><//amp-img> Note that the tag from img is changed to amp-img. Why to use amp-img instead of img? The reason behind changing img to amp-img is to have more control on the page layout and the network request made to load the image. Amp adds lazy loading to the image resource and prioritizes the loading as per other resources available on the page. Example Observe the following code for a better understanding − <!doctype html> <html amp lang = “en”> <head> <meta charset = “utf-8”> <script async src = “https://cdn.ampproject.org/v0.js”></script> <title>Google AMP – Image</title> <link rel = “canonical” href = “http://example.ampproject.org/articlemetadata.html”> <meta name = “viewport” content = “width = device-width, minimum-scale = 1,initialscale = 1”> <style amp-boilerplate> body{ -webkit-animation: -amp-start 8s steps(1,end) 0s1 normal both;-moz-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-msanimation: – amp-start 8s steps(1,end) 0s 1 normal both;animation: -amp-start 8s steps(1,end) 0s 1 normal both } @-webkit-keyframes -ampstart{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -ampstart{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -ampstart{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -ampstart{from{visibility:hidden}to{visibility:visible}}@keyframes amp-start{from{visibility:hidden}to{visibility:visible}} </style> <noscript> <style amp-boilerplate> body{ -webkit-animation:none; -moz-animation:none; -msanimation:none; animation:none } </style> </noscript> </head> <body> <h1>Google AMP – Image Example</h1> <amp-img alt = “Beautiful Flower” src = “images/flower.jpg” width = “246” height = “205”> </amp-img> </body> </html> Output When you executed the code shown above, you will find the result as shown below − You can also make the image responsive by adding property layout = ”responsive” to amp-img tag as shown below Example Observe the following code for a better understanding − <amp-img alt = “Beautiful Flower” src = “images/flower.jpg” width = “246” height = “205” layout = “responsive”> </amp-img> Output When you executed the code shown above, you will find the result as shown below − Print Page Previous Next Advertisements ”;
Google AMP – Font
Google AMP – Font ”; Previous Next Amp font is an amp-component in amp which basically helps to trigger and monitor custom fonts to amp page. This chapter discusses amp-font in detail. To work with amp-font, we need to add following javascript file − <script async custom-element = “amp-font” src = “https://cdn.ampproject.org/v0/amp-font-0.1.js”> </script> The amp-font component is used for controlling the time taken for font loading. It has a timeout attribute, which takes time in milliseconds.By default, it is 3000ms. The component allows to add/remove classes from document.documentElement or document.body depending upon whether the font required is loaded or got into an error state. The format for amp-font tag is as shown below − <amp-font layout = “nodisplay” font-family = “Roboto Italic” timeout = “2000” on-error-remove-class = “robotoitalic-loading” on-error-add-class = “robotoitalic-missing” on-load-remove-class = “robotoitalic-loading” on-load-add-class = “robotoitalic-loaded”> </amp-font> A working example on how to use amp-font in amp pages is as shown here − Example <!doctype html> <html amp lang = “en”> <head> <meta charset = “utf-8”> <script async src = “https://cdn.ampproject.org/v0.js”></script> <title>Google AMP – Amp Font</title> <link rel = “canonical” href = “http://example.ampproject.org/article-metadata.html”> <meta name = “viewport” content = “width = device-width,minimum-scale = 1,initial-scale = 1”> <style amp-boilerplate> body{ -webkit-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation: -amp-start 8s steps(1,end) 0s 1 normal both;animation: -amp-start 8s steps(1,end) 0s 1 normal both } @-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}} </style> <noscript> <style amp-boilerplate> body{ -webkit-animation:none; -moz-animation:none; -ms-animation:none; animation:none} </style> </noscript> <cript async custom-element = “amp-font” src = “https://cdn.ampproject.org/v0/amp-font-0.1.js” ></script> <style amp-custom> @font-face { font-family: ”This font is not available”; font-style: normal; font-weight: 300; src: url(fonts/MissingFont.ttf) format(”truetype”); } .font-missing { color:red; font-size:25px; } </style> </head> <body> <h1>Google AMP – Amp Font</h1> <amp-font layout = “nodisplay” font-family = “Font Does Not exist” timeout = “2000” on-error-remove-class = “font-missing” on-error-add-class = “font-error” on-load-remove-class = “font-missing” on-load-add-class = “font-loaded”> </amp-font> <p class = “font-missing”> Example of amp-font component to show how attributes on-error-remove-class, on-error-add-class, on-load-remove-class and on-load-add-class works when the font file to be loaded does not exist. </p> </body> </html> Output The output of the sample code given above is as shown below − An example of amp-font when font file loads successfully is shown here − Example <!doctype html> <html amp lang = “en”> <head> <meta charset = “utf-8”> <script async src = “https://cdn.ampproject.org/v0.js”></script> <title>Google AMP – Amp Font</title> <link rel = “canonical” href = “http://example.ampproject.org/article-metadata.html”> <meta name = “viewport” content = “width = device-width,minimum-scale = 1,initial-scale = 1”> <style amp-boilerplate> body{ -webkit-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation: -amp-start 8s steps(1,end) 0s 1 normal both;animation: -amp-start 8s steps(1,end) 0s 1 normal both } @-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}} </style> <noscript> <style amp-boilerplate> body{ -webkit-animation:none; -moz-animation:none; -ms-animation:none; animation:none} </style> </noscript> <script async custom-element = “amp-font” src = “https://cdn.ampproject.org/v0/amp-font-0.1.js”> </script> <style amp-custom> @font-face { font-family: ”This font is not available”; font-style: normal; font-weight: 300; src: url(fonts/MissingFont.ttf) format(”truetype”); } @font-face { font-family: ”Roboto Italic”; font-style: normal; font-weight: 300; src:url(fonts/Roboto-Italic.ttf) format(”truetype”); } .font-missing { color:red; font-size:25px; } .robotoitalic-loading { color: green; } .robotoitalic-loaded { font-size:25px; color: blue; } .robotoitalic-missing { color: red; } .robotoitalic { font-family: ”Roboto Italic”; } </style> </head> <body> <h1>Google AMP – Amp Font</h1> <amp-font layout = “nodisplay” font-family = “Font Does Not exist” timeout = “2000” on-error-remove-class = “font-missing” on-error-add-class = “font-error” on-load-remove-class = “font-missing” on-load-add-class = “font-loaded”> </amp-font> <p class=”font-missing”> Example of amp-font component to show how attributes on-error-remove-class, on-error-add-class, on-load-remove-class and on-load-add-class works when the font file to be loaded does not exist. </p> <amp-font layout = “nodisplay” font-family = “Roboto Italic” timeout = “2000” on-error-remove-class = “robotoitalic- loading” on-error-add-class = “robotoitalic-missing” on-load-remove-class = “robotoitalic-loading” on-load-add-class = “robotoitalic-loaded”> </amp-font> <p class = “robotoitalic”> Example of amp-font component to show how attributes on-error-remove-class, on-error-add-class, on-load-remove-class and on-load-add-class works when the font file exists and loads fine. </p> </body> </html> Output The output of the sample code given above is as shown below − The above example shows how to work with font attributes like font-family,timeout,on-error-remove-class,on-error-add-class,on-load-remove-class,on-load-add-class.The classes decide whether there is error or success in font loading. Print Page Previous Next Advertisements ”;
Google AMP – Animations
Google AMP – Animations ”; Previous Next Amp-animation is an amp component which defines animations to be used on other amp components. This chapter discusses them in detail. To work with amp-animation, we need to add following script − <script async custom-element = “amp-animation” src = “https://cdn.ampproject.org/v0/amp-animation-0.1.js”> </script> The details of animation are defined inside a json structure. The basic structure of amp-animation is as shown here − <amp-animation layout = “nodisplay”> <script type = “application/json”> { // Timing properties … “animations”: [ { // animation 1 }, … { // animation n } ] } </script> </amp-animation> The animation component consists of the following − Selectors, Variables, Timing Properties, Keyframes etc. { “selector”: “#target-id”, // Variables // Timing properties // Subtargets … “keyframes”: [] } Selector Here we need to give the class or id of the element on which the animation will be used. Variables They are the values which are defined to be used inside keyframes. Variables are defined using var(). Example { “–delay”: “0.5s”, “animations”: [ { “selector”: “#target1”, “delay”: “var(–delay)”, “–x”: “150px”, “–y” : “200px”, “keyframes”: { “transform”: “translate(var(–x), var(–y, 0px)” } } ] } Here delay, x and y are variables and the values for the variables are defined in the example shown. Timing properties Here you can define the duration and delay for your animation. The following are the timing properties supported − Property Value Description duration Time property.Value has to be in milliseconds. The duration used for animation. delay Time property.Value has to be in milliseconds. The delay before animation starts executing endDelay Time property.Value has to be in milliseconds or seconds. The delay given which applies when the animation completes. iterations Value has to be a number. The number of times the animation has to repeat. iterationStart Value has to be a number. The time offset at which the effect begins animating. easing Value is a string This is used to get the easing effect to the animation.Some examples for easing are linear , ease, ease-in, ease-out , ease-in-out etc direction Value is a string One of “normal”, “reverse”, “alternate” or “alternate-reverse”. fill Value is a string Values can be “none”, “forwards”, “backwards”, “both”, “auto”. Keyframes Keyframes can be defined in many ways such as in object form or array form. Consider the following examples. Example “keyframes”: {“transform”: “translate(100px,200px)”} Example { “keyframes”: { “opacity”: [1, 0], “transform”: [“scale(1)”, “scale(2)”] } } Example { “keyframes”: [ {“opacity”: 1, “transform”: “scale(1)”}, {“opacity”: 0, “transform”: “scale(2)”} ] } Example { “keyframes”: [ {“easing”: “ease-out”, “opacity”: 1, “transform”: “scale(1)”}, {“opacity”: 0, “transform”: “scale(2)”} ] } Keyframe using CSS <style amp-custom> div { width: 100px; height: 100px; background-color: red; position: relative; margin: 0 auto; transform:scale(3); } @keyframes example { 0% {transform:scale(3)} 75% {transform:scale(2)} 100% {transform:scale(1)} } </style> <amp-animation layout = “nodisplay”> <script type = “application/json”> { “duration”: “4s”, “keyframes”: “example” } </script> </amp-animation> There are some CSS properties that can be used inside keyframes. The supported ones are called whitelisted properties. The following are the whitelisted properties which can be used inside keyframes − opacity transform visibility ”offsetDistance” Note − Using any other property besides the white listed ones will throw error in the console. Let us now understand through a simple example which will rotate the image when the animation is applied on it. In this example, we are rotating the image using amp-animation. Example <!doctype html> <html amp lang = “en”> <head> <meta charset = “utf-8”> <script async src = “https://cdn.ampproject.org/v0.js”></script> <title>Google AMP – Amp Video</title> <link rel = “canonical” href = “http://example.ampproject.org/article-metadata.html”> <meta name = “viewport” content = “width = device-width, minimum-scale = 1,initial-scale = 1”> <style amp-boilerplate> body{ -webkit-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-ms -amp-start 8s steps(1,end) 0s 1 normal both;animation: -amp-start 8s steps(1,end) 0s 1 normal both } @-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}} </style> <noscript> <style amp-boilerplate> body{ -webkit-animation:none; -moz-animation:none; -ms-animation:none; animation:none } </style> </noscript> <script async custom-element = “amp-animation” src =” https://cdn.ampproject.org/v0/amp-animation-0.1.js”> </script> <style amp-custom> amp-img { border: 1px solid black; border-radius: 4px; padding: 5px; } </style> </head> <body> <h3>Google AMP – Amp Animation Example</h3> <amp-animation id = “anim1” layout = “nodisplay” trigger = “visibility”> <script type = “application/json”> { “duration”: “1s”, “fill”: “both”, “direction”: “alternate”, “animations”: [ { “selector”: “#image1”, “easing”: “cubic-bezier(0,0,.21,1)”, “keyframes”: { “transform”: “rotate(20deg)” } } ] } </script> </amp-animation> <br/> <br/> <amp-img id = “image1” src = “images/christmas1.jpg” width = 300 height = 250 layout = “responsive”> </amp-img> <br/> </body> </html> Output The details of amp-animation details used above are given in the code shown below − <amp-animation id = “anim1” layout = “nodisplay” trigger = “visibility”> <script type = “application/json”> { “duration”: “1s”, “fill”: “both”, “direction”: “alternate”, “animations”: [ { “selector”: “#image1”, “easing”: “cubic-bezier(0,0,.21,1)”, “keyframes”: { “transform”: “rotate(20deg)” } } ] } </script> </amp-animation> The selector here is the id of the image on which the rotate animation is applied − <amp-img id = “image1” src = “images/christmas1.jpg” width = 300 height = 250 layout = “responsive”> </amp-img> Example using Keyframes from CSS Example <!doctype html> <html amp lang = “en”> <head> <meta charset = “utf-8”> <script async src = “https://cdn.ampproject.org/v0.js”></script> <title>Google AMP – Amp Video</title> <link rel = “canonical” href = “http://example.ampproject.org/article-metadata.html”> <meta name = “viewport” content = “width = device-width,minimum-scale = 1,initial-scale = 1”> <style amp-boilerplate> body{ -webkit-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation: -amp-start 8s steps(1,end) 0s 1 normal both;animation: -amp-start 8s steps(1,end) 0s 1 normal both } @-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}} </style> <noscript> <style amp-boilerplate> body{ -webkit-animation:none; -moz-animation:none; -ms-animation:none; animation:none } </style> </noscript> <script async custom-element = “amp-animation” src = “https://cdn.ampproject.org/v0/amp-animation-0.1.js”> </script> <style amp-custom> div { width: 100px; height: 100px; background-color: red; position: relative; margin: 0 auto; transform:scale(3); } @keyframes example { 0% {transform:scale(3)} 75% {transform:scale(2)} 100% {transform:scale(1)} } </style> </head> <body> <h3>Google AMP – Amp Animation Example</h3> <amp-animation id = “anim1” layout = “nodisplay” trigger = “visibility”> <script type = “application/json”> { “duration”: “3s”, “fill”: “both”,
Google AMP – Home
Google AMP Tutorial PDF Version Quick Guide Resources Job Search Discussion Accelerated Mobile Pages (AMP) is Google”s open source project specially designed to make the web pages mobile friendly by making it render contents faster, smoother and more responsive in any browser. This tutorial gives you a comprehensive coverage of concepts of Google AMP and makes you comfortable to use it in your software development projects. Audience This tutorial is designed for software programmers who want to learn the basics of Google AMP and its programming concepts in simple and easy ways. This tutorial will give you enough understanding on various functionalities of Google AMP with suitable examples. Prerequisites This tutorial is written assuming that the learner has a prior understanding of HTML, CSS, and Javascript. In case you are new to any of these technologies, we suggest you to pick a tutorial based on these first, before beginning your learning with Google AMP. Print Page Previous Next Advertisements ”;
Styles And Custom CSS
Google AMP – Styles and Custom CSS ”; Previous Next Amp renders the pages on the screen after a lot careful consideration.The pages loaded will contain images, videos, iframes etc., which are more of http requests to be done. So the http request to be done are delayed so that the content on the page is displayed and also a necessary space is created for the images, videos, iframes to be loaded. Amp has features such as placeholders, fallbacks, srcset and layout attribute to make the pages responsive and also makes sure the content on the page is not disturbed. In this chapter, let us discuss all these in detail. Amp Style Tag Amp has a style tag with amp-custom on it as shown below − <style amp-custom> button{ background-color: #ACAD5C; color: white; padding: 12px 20px; border: none; border-radius: 4px; cursor: pointer; float: left; } amp-img { border: 1px solid black; border-radius: 4px; padding: 5px; } p { padding: 1rem; font-size:25px; } largeText { font-size:30px; background-color:red; } </style> It is basically used to write the custom css required for the page. Please do not forget to add the amp-custom attribute; otherwise it will fail for amp validation as shown below − Amp also supports inline css for html elements as shown below − <div style = “color:green;margin-left:30px;”> Welcome to TutorialsPoint</p> External Stylesheet Tag Amp does not support external stylesheet and will fail for validation when validated for amp. Example <!doctype html> <html amp lang = “en”> <head> <meta charset = “utf-8”> <script async src = “https://cdn.ampproject.org/v0.js”></script> <title>Google AMP – Dynamic Css Classes</title> <link rel = “canonical” href = ” http://example.ampproject.org/article-metadata.html”> <meta name = “viewport” content = “width = device-width,minimum-scale = 1,initial-scale = 1”> <style amp-boilerplate> body { -webkit-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation: -amp-start 8s steps(1,end) 0s 1 normal both;animation: -amp-start 8s steps(1,end) 0s 1 normal both } @-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}} </style> <noscript> <style amp-boilerplate> body { -webkit-animation:none; -moz-animation:none; -ms-animation:none; animation:none } </style> </noscript> <script async custom-element = “amp-bind” src = ” https://cdn.ampproject.org/v0/amp-bind-0.1.js”> </script> <script async custom-element = “amp-dynamic-css-classes” src = “https://cdn.ampproject.org/v0/amp-dynamic-css-classes-0.1.js”> </script> <link rel = “stylesheet” href = “https://cdnjs.cloudflare.com/ajax/libs/materialize/0.9 8.0/css/materialize.min.css”> <style amp-custom> p { padding: 1rem; font-size:25px; } </style> </head> <body> <h3>Google AMP – Dynamic Css Classes</h3> <div style = “color:green;margin-left:30px;”> Welcome to TutorialsPoint</p> </body> </html> When validated with AMP validator, we get the following error. To display the elements in the page responsively, amp elements need to specify the width and the height the element will take on the page. Adding layout = “responsive” will make the element responsive on the page maintaining the aspect ratio. The details of layout attribute is discussed in detail in the chapter Google AMP – Layout. Print Page Previous Next Advertisements ”;
Google AMP – Timeago
Google AMP – Timeago ”; Previous Next Timeago will give the timestamp details by comparing it to the past, for example ‘x’ hours ago. In this chapter, let us discuss in detail about this feature. To insert this feature in our work, we need to add the script given below to the .html page − <script async custom-element = “amp-timeago” src = “https://cdn.ampproject.org/v0/amp-timeago-0.1.js”> </script> The amp-timeago tag looks as shown below − <amp-timeago layout = “fixed” width = “160” height = “20” datetime = “2018-10-01T00:37:33.809Z” locale = “en”>Monday 01 October 2018 00.37 </amp-timeago> Let us understand this with the help of a working example as shown below − Example <!doctype html> <html amp lang = “en”> <head> <meta charset = “utf-8”> <script async src = “https://cdn.ampproject.org/v0.js”></script> <title>Google AMP – TimeAgo</title> <link rel = “canonical” href = ” http://example.ampproject.org/article-metadata.html”> <meta name = “viewport” content = “width = device-width,minimum-scale = 1,initial- scale = 1″> <style amp-boilerplate> body{ -webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation: -amp-start 8s steps(1,end) 0s 1 normal both;animation: -amp-start 8s steps(1,end) 0s 1 normal both } @-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}} </style> <noscript> <style amp-boilerplate> body{ -webkit-animation:none;-moz-animation:none;-ms -animation:none;animation:none } </style> </noscript> <script async custom-element=”amp-timeago” src = “https://cdn.ampproject.org/v0/amp-timeago-0.1.js”> </script> </head> <body> <h1>Google AMP – TimeAgo Example</h1> <amp-timeago layout = “fixed” width = “160” height = “20” datetime = “2018-10-01T00:37:33.809Z” locale = “en”>Monday 01 October 2018 00.37 </amp-timeago> </body> </html> Output By default, the locale is set to en. We can change the same and display timeago in the locale as needed. Locales which can be used with timeago tag are given in the table shown below. Sr.No Locale & Description 1 ar Arabic 2 be Belarusian 3 be Belarusian 4 bg Bulgarian 5 ca Catalan 6 da Danish 7 de German 8 el Greek 9 en English 10 enShort English – short 11 es Spanish 12 eu Basque 13 fi Finnish 14 fr French 15 he Hebrew 16 hu Hungarian 17 inBG Bangla 18 inHI Hindi 19 inID Malay 20 it Italian 21 ja Japanese 22 ko Korean 23 ml Malayalam 24 nbNO Norwegian Bokmål 25 nl Dutch 26 nnNO Norwegian Nynorsk 27 pl Polish 28 ptBR Portuguese 29 ro Romanian 30 ru Russian 31 sv Swedish 32 ta Tamil 33 th Thai 34 tr Turkish 35 uk Ukrainian 36 vi Vietnamese 37 zhCN Chinese 38 zhTW Taiwanese Let us discuss few locales using working examples as given below − Example <!doctype html> <html amp lang = “en”> <head> <meta charset = “utf-8”> <script async src = “https://cdn.ampproject.org/v0.js”></script> <title>Google AMP – TimeAgo Using Locale</title> <link rel = “canonical” href = “http://example.ampproject.org/article-metadata.html”> <meta name = “viewport” content = “width = device-width,minimum-scale = 1, initial-scale = 1”> <style amp-boilerplate> body{ -webkit-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation: -amp-start 8s steps(1,end) 0s 1 normal both;animation: -amp-start 8s steps(1,end) 0s 1 normal both } @-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}} </style> <noscript> <style amp-boilerplate> body{ -webkit-animation:none; -moz-animation:none;-ms -animation:none; animation:none } </style> </noscript> <script async custom-element = “amp-timeago” src = “https://cdn.ampproject.org/v0/amp-timeago-0.1.js”> </script> </head> <body> <h1>Google AMP – TimeAgo Example Using Locale</h1> <h3>Locale : Russian</h3> <amp-timeago layout = “fixed” width = “160” height = “20” datetime = “2018-10-01T00:37:33.809Z” locale = “ru”> Monday 01 October 2018 00.37 </amp-timeago> <h3>Locale : Korean</h3> <amp-timeago layout = “fixed” width = “160” height = “20” datetime = “2018-10-01T00:37:33.809Z” locale = “ko”> Monday 01 October 2018 00.37 </amp-timeago> <h3>Locale : Hindi</h3> <amp-timeago layout = “fixed” width = “160” height = “20” datetime = “2018-10-01T00:37:33.809Z” locale = “inHI”> Monday 01 October 2018 00.37 </amp-timeago> <h3>Locale : Spanish</h3> <amp-timeago layout = “fixed” width = “160” height = “20” datetime = “2018-10-01T00:37:33.809Z” locale = “es”> Monday 01 October 2018 00.37 </amp-timeago> <h3>Locale : French</h3> <amp-timeago layout = “fixed” width = “160” height = “20” datetime = “2018-10-01T00:37:33.809Z” locale = “fr”> Monday 01 October 2018 00.3 </amp-timeago> </body> </html> Output The output of the above code is as shown below − Incase the “X time ago” display needs to be changed, we can use the “cutoff” attribute with timeago. Cutoff takes values in seconds to get rid of the ago display. Let us understand this with the help of a working example as given below − Example <!doctype html> <html amp lang = “en”> <head> <meta charset = “utf-8”> <script async src = “https://cdn.ampproject.org/v0.js”></script> <title>Google AMP – TimeAgo</title> <link rel = “canonical” href = “http://example.ampproject.org/article-metadata.html”> <meta name = “viewport” content = “width = device-width,minimum-scale=1, initial-scale=1”> <style amp-boilerplate> body{ -webkit-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation: -amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation: -amp-start 8s steps(1,end) 0s 1 normal both;animation: -amp-start 8s steps(1,end) 0s 1 normal both } @-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}} </style> <noscript> <style amp-boilerplate> body{ -webkit-animation:none; -moz-animation:none; -ms-animation:none; animation:none } </style> </noscript> <script async custom-element = “amp-timeago” src = “https://cdn.ampproject.org/v0/amp-timeago-0.1.js”> </script> </head> <body> <h1>Google AMP – TimeAgo Example</h1> <amp-timeago layout = “fixed” width = “160” height = “20” datetime = “2018-10-01T00:37:33.809Z” locale = “en” cutoff = “300”> Monday 01 October 2018 00.37 </amp-timeago> </body> </html> Output Print Page Previous Next Advertisements ”;