Adding Scripts Properly to WordPress Part 1 – wp_enqueue_script

Posted by admin in HOW-TO, jquery, admi... | 05.07.2010 - 7:04 am

Starting in WordPress 2.1 (if I remember correctly), the awesome folks at Automattic gave us the even awesomer function of wp_enqueue_script.
Before that, it was every plugin or theme author for himself. If you wanted to add in a script, it was hard-coded in.
As you might imagine, this presented a ton of problems. Scripts were loaded twice, out of order, or even when they weren’t needed at all.
Furthermore, some themes and plugins had the JavaScript embedded within the plugin’s or theme’s PHP file just to capture a few PHP variables. Not good! In order to add scripts properly to JavaScript, you must always keep your PHP and JavaScript separate. And by separate, I mean separate files. There’s just no excuse anymore (I’ll get into this in Part 2 of this series).
The wp_enqueue_script function is the first step in loading your scripts properly. Not only […]

Original post by Ronald Huereca

    Technorati Tags:

    Related Posts:
  1. Adding Scripts Properly to WordPress Part 2 – JavaScript Localization
  2. ...
  3. Adding Scripts Properly to WordPress Part 3 – Page Detection
  4. ...
  5. Adding Menus To The Admin Bar
  6. ...
  7. Ian Stewart On Child Themes - Part 2
  8. ...
  9. Scaling WordPress Part 1: Using MySQL Replication and HyperDB
  10. ...
  11. Best Of WLTC Part 1
  12. ...
  13. From Blogger To WordPress
  14. ...
  15. Tackle Plugin Compatibility Issues While Using Popular Libraries
  16. ...
  17. Install WordPress Locally - Part 2 Of 2
  18. ...
  19. Best Of WLTC Part 2
  20. ...
  21. CSS3 Image Styles – Part 2
  22. ...
  23. Watch Out For The Gumblar Botnet
  24. ...
  25. Plugin Review: cSprites for WordPress
  26. ...
  27. 2in1 Security Bulletin
  28. ...
  29. 2 Plugin Security Bulletins
  30. ...

  31. No Comments on "Adding Scripts Properly to WordPress Part 1 – wp_enqueue_script" »

    No comments yet.

    Leave a comment