WordPress Tips, Tricks and Techniques

How To Embed Javascript

Using a standard WordPress block, you may be surprised how easy it is to embed javascript.

All you need to do is add an HTML block, add <script> and </script> tags, then put what you want between them.

Any javascript between the tags will execute as soon as the block is parsed.

For that reason, you may want the page’s elements with which the script will interact fully developed first, so the best place for the block would be at the bottom of the page.

Here’s an example from the Understanding Colors post:

Notice that the first two elements above are also HTML blocks which were used to create the divs on which the javascript will operate.

Here it is in operation:


See also: How To Build A Converter

Leave a Reply

Your email address will not be published. Required fields are marked *

There is no need to be confused, frustrated, or waste time with WordPress issues. I’ll be glad to help with phone or screen sharing. I charge $2/minute, with no minimum. The typical call runs 9 minutes ($18). If I can’t efficiently solve your problem, there’s no charge for the call. Contact me any time at (805)-843-5353. You’ll enjoy my friendly, informative manner! – Jeff