All Collections
API / Customization / Advanced
Wrapping Your Javascript with pvReady() Makes Your Code Work in the Builder
Wrapping Your Javascript with pvReady() Makes Your Code Work in the Builder

If you're running javascript on the page or embedded in your code, make sure you wrap it with pvReady().

Updated over a week ago

The pvReady function works just like the jQuery $(document).ready() function in where it waits to execute any sub functions until the page has loaded. This is required for when editing the page in the builder to prevent your javascript from rendering. Alternatively you can add your JS to the page_js section to achieve the same results.

If you do have inline javascript on your page between <script></script> tags, then wrap the inner text of the <script> with:

pvReady(function(){ console.log("ready");}
Did this answer your question?