performance - Wordress importing scripts

I am fairly new to Wordpress theme development, and I'm trying to structure my code using the best practices possib

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
Add a comment  | 

1 Answer 1

Reset to default 2

Option 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744866090a4597984.html

相关推荐

  • performance - Wordress importing scripts

    I am fairly new to Wordpress theme development, and I'm trying to structure my code using the best practices possib

    2天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信