Contents
But this code snipped assumes that you’re the one queueing the script, i.e. you’re doing this in your own plugin or theme. At the moment, there is no way to add an in-line script to the WordPress footer and also load it with dependencies. But there is an alternative, if you’re willing.
Can you add a snippet to a page in Divi?
If you are looking to add a javascript (or jquery) snippet to a single page in Divi, you can use the Code Module. This will make sure the JS doesn’t get loaded on every page unnecessarily, causing a minor increase in page load time on pages that don’t even need it.
Where to place JS snippets on a page?
For most cases, it would be best to add JS snippets to the body. This will actually place your snippet at the bottom of your page so that it loads after everything else which is great for page load speed.
Do you start with a footer in jQuery?
Note: your footer must start with and end with to use this code as is, or you can modify the code to match your footer’s id/class.
Is it possible to insert code snippets in WordPress?
Directly inserting such code snippets on WordPress posts and pages is not possible. You can insert plain HTML code under “Text” editor but CSS and JavaScript can’t be added in-between content. There are very few plugins on the WordPress repository available for this purpose.
Which is the best plugin for inserting a header and footer?
For the first plugin on your list, we have Insert Header and Footer for WordPress from the people over at WPBeginner. It is a very simple and user-friendly plugin which allows you to easily insert code snippets for integrating services like Google Analytics, Facebook Pixel, and even Custom CSS.
At the moment, there is no way to add an in-line script to the WordPress footer and also load it with dependencies. But there is an alternative, if you’re willing. When WordPress works with scripts, it loads them internally to an object to keep track of them. There are essentially 3 lists inside the object: