简体   繁体   中英

How can I include/require foreign JavaScript libraries in WordPress?

I am writing an interactive google map in javascript for a wordpress page. As far as I know, the only way to use javascript with wordpress is by creating a separate .js file and just calling the methods from there within the wordpress page. So my question is, if I need to use the google maps api in my javascript code, how do I 'include' it within the .js file instead of using a <script> tag in the html?

AFAIK there is no include in javascript. Take a look at wp_enqueue_script() .

Edit

Just stumbled over the yepnope.js library by Alex Sexton. Maybe this is what you are looking for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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