Notice: Function wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the codepen-embed-script handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/jwblogger/jwBlogger/wp-includes/functions.php on line 6114

Warning: Cannot modify header information - headers already sent by (output started at /home/jwblogger/jwBlogger/wp-includes/functions.php:6114) in /home/jwblogger/jwBlogger/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home/jwblogger/jwBlogger/wp-includes/functions.php:6114) in /home/jwblogger/jwBlogger/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home/jwblogger/jwBlogger/wp-includes/functions.php:6114) in /home/jwblogger/jwBlogger/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home/jwblogger/jwBlogger/wp-includes/functions.php:6114) in /home/jwblogger/jwBlogger/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home/jwblogger/jwBlogger/wp-includes/functions.php:6114) in /home/jwblogger/jwBlogger/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home/jwblogger/jwBlogger/wp-includes/functions.php:6114) in /home/jwblogger/jwBlogger/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home/jwblogger/jwBlogger/wp-includes/functions.php:6114) in /home/jwblogger/jwBlogger/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home/jwblogger/jwBlogger/wp-includes/functions.php:6114) in /home/jwblogger/jwBlogger/wp-includes/rest-api/class-wp-rest-server.php on line 1893
{"id":333,"date":"2018-04-03T15:20:53","date_gmt":"2018-04-03T22:20:53","guid":{"rendered":"http:\/\/blog.jeffwilkerson.net\/?p=333"},"modified":"2018-04-03T15:20:53","modified_gmt":"2018-04-03T22:20:53","slug":"abstracting-youtube-api-loading","status":"publish","type":"post","link":"https:\/\/blog.jeffwilkerson.net\/2018\/04\/03\/abstracting-youtube-api-loading\/","title":{"rendered":"Abstracting Youtube API Loading"},"content":{"rendered":"

I’ve been on several projects when I was asked to display Youtube videos on a webpage. Well, unless there is only one video on the page, and that video is loaded statically, you might need to leverage the Youtube API<\/a>.<\/p>\n

Every time I’ve placed a Youtube video on a page, its never as easy as slapping an IFRAME on the page. Sometimes the video loads dynamically, like when opening a modal window. Sometimes there is more than one video on the page, and you need to control the videos via javascript so that only one video plays at a time. Sometimes the web page being loaded needs to be as quick as possible, and therefore need to initialize videos on demand. To say to least, I almost always make use of the Youtube API to display videos on web pages.<\/p>\n

I’ve posted a helper module to my Github account<\/a> that abstracts the details of loading the API. The module encapsulates the code needed to load the API library asynchronously and also defines the required `onYouTubeIframeAPIReady` function that is called once the API is loaded and ready. The function fires an event from the body to notify other modules that the API is ready. Once the API is ready, modules can initialize players.<\/p>\n

Default Usage<\/h3>\n
\t\n     var ytHelper = new YoutubeHelper();\n     ytHelper.init(function() {    \t\n\n     \t\/\/ DO SOMETHING ONCE API IS READY\n\n     });<\/pre>\n","protected":false},"excerpt":{"rendered":"

This module encapulates the functionality needed to load the Youtube API<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[13],"class_list":["post-333","post","type-post","status-publish","format-standard","hentry","category-development","tag-javascript"],"_links":{"self":[{"href":"https:\/\/blog.jeffwilkerson.net\/wp-json\/wp\/v2\/posts\/333","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jeffwilkerson.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jeffwilkerson.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jeffwilkerson.net\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jeffwilkerson.net\/wp-json\/wp\/v2\/comments?post=333"}],"version-history":[{"count":0,"href":"https:\/\/blog.jeffwilkerson.net\/wp-json\/wp\/v2\/posts\/333\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jeffwilkerson.net\/wp-json\/wp\/v2\/media?parent=333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jeffwilkerson.net\/wp-json\/wp\/v2\/categories?post=333"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jeffwilkerson.net\/wp-json\/wp\/v2\/tags?post=333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}