{"id":334,"date":"2012-01-18T20:00:14","date_gmt":"2012-01-19T01:00:14","guid":{"rendered":"http:\/\/www.cloppermillweather.org\/blog\/?p=334"},"modified":"2012-01-18T20:02:39","modified_gmt":"2012-01-19T01:02:39","slug":"updating-forecast","status":"publish","type":"post","link":"https:\/\/www.cloppermillweather.org\/blog\/2012\/01\/18\/updating-forecast\/","title":{"rendered":"Updating Forecast"},"content":{"rendered":"<p>The revised site has been running for several days now.\u00a0 Not having as many problems as I expected.\u00a0 That&#8217;s a good thing.\u00a0 So I decided to add a new feature.\u00a0 I tend to leave the Web page open for hours at a time and look at the station data periodically, as it updates automatically.\u00a0 The problem is that the forecast from he NWS is static.\u00a0 To get ti to update requires clicking on the button to refresh that page.\u00a0 So I added code to have it update automatically.\u00a0 My NWS forecast PHP class now can serialize itself to JSON.\u00a0 I created a new page that returns that JSON data to the browser.\u00a0 And I added client side Knockout data binding for those fields.\u00a0 So far so good.<\/p>\n<p>While I was testing the data binding, I learned that I had a bug in my Knockout code.\u00a0 If I had used proper JavaScript exception handling I would have noticed it earlier.\u00a0 I was retrieving the data from the server on a schedule, with some data refreshing more frequently than other data.\u00a0 What I didn&#8217;t realize was that Knockout was throwing exceptions when I mapped the data model up until I retrieved all of the fields at least once.\u00a0 So now I &#8220;prime the pump&#8221; and retrieve everything once up front.\u00a0 I had to add that code to all of my Web pages that use Knockout.\u00a0 Then I added a bit more exception handling code.\u00a0 I&#8217;m not happy with it, but at least I have something there.\u00a0 I also found a bug in one field that caused it to show as zero most of the time.\u00a0 So I fixed that one as well.<\/p>\n<p>I also made the mistake of running my pages past a Web page optimization site.\u00a0 Of course I got called out for having so much JavaScript code.\u00a0 So I added minify to my Web site.\u00a0 Minify is PHP code to combine and compress multiple JavaScript files on demand.\u00a0 That helped my load times out a bit, and the optimizer had one less thing to complain about.\u00a0 There&#8217;s still some more I can do to make the pages load a little bit faster.\u00a0 So I may still do some more work in that area.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The revised site has been running for several days now.\u00a0 Not having as many problems as I expected.\u00a0 That&#8217;s a good thing.\u00a0 So I decided to add a new feature.\u00a0 I tend to leave the Web page open for hours &hellip; <a href=\"https:\/\/www.cloppermillweather.org\/blog\/2012\/01\/18\/updating-forecast\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-334","post","type-post","status-publish","format-standard","hentry","category-weather"],"_links":{"self":[{"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/posts\/334","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/comments?post=334"}],"version-history":[{"count":0,"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/posts\/334\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/media?parent=334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/categories?post=334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/tags?post=334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}