Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

188
Views
How do I use custom javascript through amp-script?

Not a seasoned programmer but getting a handle on javascript, css, html. I have been successful in creating and loading javascript to use in my standard HTML files. I would like to start using AMPHTML and need to use my own JavaScript for some interaction. Are there some concrete stem-to-stern examples out there? Google AMP's own documentation leaves much to be desired for the uninitiated.

  1. I have reviewed the documentation, written my code (passing AMP verification before using amp-script.
  2. Supposedly, I have imported my javascript per the method shown in the documentation. I do not understand what the width and height attributes are there for, or what layout container or fixed has to do with anything.
  3. Going by the AMP documents and checking Source in the Development Tools, my file blogHub.js has been accessed and loaded. I see the file there as mentioned and that supposedly means I can use those functions...

So now, I am trying to see some signs of life from my javascript by trying to run functions which spit out console.log messages, but I see nothing. No doubt this is a simple problem for many, but it has me stumped for the moment.

Is sandwiching the relevant code between the tags a way to corral a separate section away from the rest of the AMP environment or the rest of the DOM?

My desire is to write javascript code which will bring in a .csv file containing information of past blog posts, then update the blog page with this information, then allow the selection of these articles for display in the amp-iframe. It should not be necessary to go into all of that code written or unwritten. I just need to know how to begin using my own javascript from within and AMP document. I am only using Vanilla JavaScript as I am not up to using any of those other libraries at this point. There should not be a need to do so, in any case.

A link to my "sandbox" early version of the page I am working on is found here -- https://michaelsbookcorner.com/HTML-blog/blogFiles/AXX-blogHub.html

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!