Archived topic
Best way to add 'Javascript' to a page (embedding)?
8 replies · Started by Andy on April 3, 2020
Hi there,
I have a short form that I usually embed on my landing pages (made with Javascript).
Looks similar to this:
<script type="text/javascript">
/* Short Form */
var test = {
"name": {
"email": ""
},
</script>
<script src="//test.com/js/serve.js"></script>
How should I embed a code like this on my landing page? Should I use the Classic editor? I don't want to run into any issues.
Thank you,
Andy
Hi there,
That can usually go into wp_footer hook using a hook element:
https://docs.generatepress.com/article/hooks-element-overview/
Just clarifying, this isn't a pop-up though. I'm embedding a single form on 1 page. Similar to embedding a youtube video with iframe.
Do I still need to use hooks? Thank you
Maybe try the Classic block?
If not then just go with the classic editor.
Thanks!
Actually Leo, I'm having issues using the Classic block.
In a previous theme, I was able to add javascript code to my page with a javascript block. Is there any way to add a javascript block like this?
https://imgur.com/a/IhMttuD
There isn't a javascript block from Gutenberg.
Maybe try the HTML block?
I think that worked, thank you. I'll test it out.
No problem :)