简体   繁体   English

将脚本从身体移动到头部

[英]Move script from body to head

I'm running into an issue with WordPress and form embeds.我遇到了 WordPress 和表单嵌入问题。 I have a page built via WP Bakery and one of the block allows a user to embed a form onto the page.我有一个通过 WP Bakery 构建的页面,其中一个块允许用户将表单嵌入到页面上。

This however is causing the form to load in slow (sometimes takes up to three seconds for the form to load in).然而,这会导致表单加载缓慢(有时加载表单需要长达三秒的时间)。

As a solution to this, I'm trying to get the <script> tags to render in the head rather than in the body .作为对此的解决方案,我试图让<script>标签呈现在head而不是body

Is this even possible?这甚至可能吗? The script needs to move into the head before page load so that the form renders in - but unsure if this is even feasible? script需要在页面加载之前移入head ,以便表单呈现 - 但不确定这是否可行?

您可以附加async加载脚本异步。

<script async src="..."></script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM