admin管理员组文章数量:1404923
I am fairly new to Wordpress theme development, and I'm trying to structure my code using the best practices possible In your opinion whats the better option to import javascript files:
OPTION 1
<script src="<?php bloginfo('template_url'); ?>/js/anime.min.js"></script
OPTION 2
wp_enqueue_script('some_script(s)');
in terms of loading time ?
Thanks in advance !
I am fairly new to Wordpress theme development, and I'm trying to structure my code using the best practices possible In your opinion whats the better option to import javascript files:
OPTION 1
<script src="<?php bloginfo('template_url'); ?>/js/anime.min.js"></script
OPTION 2
wp_enqueue_script('some_script(s)');
in terms of loading time ?
Thanks in advance !
Share Improve this question asked Jan 2, 2020 at 15:56 Pedro FerreiraPedro Ferreira 1791 silver badge10 bronze badges 3- Where in the page are you putting option 1? That's likely the only difference in load time, as option 2 will also generate a script tag but put it at the end of the page by default. – Rup Commented Jan 2, 2020 at 15:58
- the option 1 was used in the footer.php – Pedro Ferreira Commented Jan 2, 2020 at 16:24
- Then they should be equivalent. wp_enqueue_script will generate script tags where your footer.php calls wp_footer. – Rup Commented Jan 2, 2020 at 16:25
1 Answer
Reset to default 2Option 2. Option 1 is just flat out incorrect, not a valid alternative. The proper methods for loading CSS and JavaScript in WordPress are documented here. Also, there's no meaningful performance difference between the two.
本文标签: performanceWordress importing scripts
版权声明:本文标题:performance - Wordress importing scripts 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744866089a2629352.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论