Project number 7 is short and sweet to help me catch up on my intended schedule to feature one project and update per week. I’ve been falling behind lately as other endeavours have distracted me. And fellas, remember, that just because it’s short that doesn’t mean it lacks utility.
This week, I wrote a lazy image loader script. Why? Because several months ago I created a website for an online community I’ve been a part of forever that would offer quick access to community members’ Twitch.TV streams. As I built the page up, it was suggested I also include streamer highlights. So I did. As the list of streamers grew, so, too, did the list of highlights. Since each highlight featured a small picture, it quickly became less than optimal to simply load every image on each page load. At the time I didn’t know how to make a lazy image loader script so I found one via google and used that.
Now I know how to make my own, however, and I’ll share it with you.
Oh, hello again. I know this one is late but I like to think it can be excused. Missile Defense (a knock-off / remix of the 1980 Atari classic Missile Command) is about 850 lines of code compared to my first five projects which have averaged about 350 lines of code. I’m also still working 40 hours a week at my non-coding day job and I do need some down time so my brain doesn’t melt. But enough excuses! Let’s do this.
As an amateur developer, there are often concepts that I didn’t consider (due to a lack of awareness) prior to writing code. Sometimes when researching I get lucky and stumble across a better way to do things and sometimes I get lucky in that someone offers constructive advice and suggestions. With this project, commenter Peter pointed out that I should look into best practices regarding namespacing. The latter link provides a good breakdown of what namespacing is and why it’s important. In a nutshell, namespacing matters when you want your code to be easily adoptable because, in practice, it ensures that you run as little risk as possible in creating a function/global variable that will step on the toes of another script using an identically named function or variable.
Over the last week and change I’ve been working on a side project dealing with one of my many non-coding related interests. Said project involved the use of a Google map and some markers to highlight points of interest. Learning all of the ins, outs, and oddities that come with the Google Maps API required to power my project was a bit of a pain in the arse. That spurred me–after the fact, of course–to try to simplify use of the Google Maps API and create an easy to use general purpose map creation tool. So that became my project for week #4. With SimpleGMaps.js, you, as a programmer, can control many of the Google Maps API options without having to actually tinker with the API directly.
See it plugged into a template found via a Google search or in a local business type use-case.
This code review will be formatted a little differently than my other code reviews to this point. I feel that if SimpleGMaps.js is going to be of any use to anyone I should explain what it is, why you may be interested in it, and how to use it before I do my usual process walk-through.
Read on to learn more about SimpleGMaps.js (or view my other code reviews here).
My third code review project (1 here, 2 here) deviates from my previous two in that there is no real user interaction beyond scrolling. This one is a bit smaller in terms of scope than the previous two and there’s a good reason for that.