Nitro Cold Brew 7/5/19
Coffee Shop Day 7/5/19
What is the 4th of July 7/5/19
Being Ecological 7/4/19
❖ BNJMN | Performance Update 7/4/19
I just finished an update to the site that should dramatically improve its download performance. I shrunk the images down a ton, and wrote some javascript that loads images in a more pleasing, controlled way.
When I first conceived this site, I was thinking of it mostly as a text based site. The photo aspect of it was thrown in as an afterthought. As time progressed I found that I really liked posting images more than anything. It has gotten to the point where well over half of my posts are images, so I was time to revise the way the site handles images. Load times were awful, because I was just dumping these big image files to the browser, and it would try to download them all at once.
I took a two-pronged approach to solving the issue: 1) reformat the images to reduce image size, & 2) make it so the images didn’t try to load all at one at time.
Just Make them Smaller
The way I upload photos to the site is using an iOS shortcut that I wrote, so it was pretty simple to go into there and revise the resizing function so it scales all the way down to 1000px wide (previously it was set to 2500px, which is kinda insane). And because of the nature of being a static site, it was really simple to go into my photos and use an app called PhotoBulk to tear through and resize them all. That process alone made the site 150% smaller, which frankly solved 80% of the problem.
Cicada Function
The way that I made the site serve images smarter relies on Javascript. I rewrote the HTML source code so that the HTML doesn’t actually download the file, but still has the link embedded as data in the img tags. Then I wrote a function that finds all the images and downloads them one at a time.
The cool thing about the function is that it’s what I’m calling a Cicada Function (I’m sure there is a real term for this that hardcore programing people know. Not me though.) The way it works is it takes the data in the img tag and reassigns it to be the image source, which causes the image to start to load. At this point the function is almost done, but right before it ends, it adds an event listener to the img that tells it to run this same function on the next image once this image is done loading. It’s like a loop, but the function is actually not running most of the time. Sort of like the way Cicadas sleep for years underground, and just emerge for a few days to lay eggs and die, restarting the cycle.
Honestly, I don’t know what the precise best practice for this particular goal would have been, but I think that this does the trick and it’s conceptually fun.
Much Better
This site has always been very performant by most metrics, so it’s evaluation by the web bots hasn’t changed that much, but the total page load times are like 3x quicker at least and experientially it’s even better, because you don’t have to wait nearly as long for the first images to load. So far it seems like the lower res images still have enough quality for the site, even if it’s not as fun to view them blown up to full size.
Enjoy!
❖ ❖
Cercropia Moth 7/2/19
//BNJMN (7/1/19): Medium is so frustrating. You can tell they know what a good reading experience would be like, but none-the-less they consistently find ways to obscure content.
//BNJMN (6/30/19): Went on a short hike this afternoon but it was so hot I didn’t even feel like taking any photos. Alas, how will I prove it?!
It’s Very Hot Outside 6/30/19
//BNJMN (6/30/19): I’d never really gotten why Aaron Copland was considered great, but I’m listening to Appalachian Spring this morning and it’s really clicking.
//BNJMN (6/29/19): I need to get back in the habit of posting more asides. Here’s one: I’m watching ‘All the President’s Men’. So far it’s fine. A little slow paced, but I like the hard boiled vibe that it has. I don’t think it has any scoring at all at this point.
↬ Week 26: Haunted by Butterflies 6/29/19
Bug on Grass 6/29/19
Bumblebee 6/29/19
My New Bug Buddy 6/29/19
Sno Cone Guy 6/29/19
Walter wants Out 6/28/19
Ricky 6/26/19
Arabian Nights 6/24/19
Shane’s Red Truck 6/23/19
Farm Dog 6/23/19
Zane and Zander 6/23/19
Hiking at Volga 6/23/19
↬ Caroline Smith 6/20/19
I love this girl. Her album ‘Half about Being a Woman’ is one of my all time favs. I was just wondering what happened to her and discovered she’d moved to LA, changed her name to ‘Your Smith’, and is putting out new music.
Wandering the Concourse 6/19/19
//BNJMN (6/19/19): I’m not a huge baseball fan, in the sense that I don’t follow it closely, but I do love ball games. It’s the perfect sport for an outing, because it’s not just about the game. It’s a pastoral sport that doesn’t demand your constant attention, so you’re free to wander the concourse with a beer and a camera for a few innings, and still fully enjoy the game. The Twins lost today, but it was a very nice evening.
That good ballpark food 6/19/19
Twins lose 9-4 6/19/19
Practical and Stylish 6/19/19
Target Field 6/19/19
Twins vs Red Sox 6/19/19
//BNJMN (6/18/19): Launches Adobe Illustrator…waits…waits…oh crap, why has the screen going black? Why are the fans spinning up like a Blackhawk?…jams power button until it stops…now waits for the computer to grumpily restart. Launches Adobe Illustrator…waits…
Georgia Peaches 6/18/19
The Rose Bush 6/17/19
Boy am I Mad! 6/17/19
Ufda Lady 6/17/19
↬ Make the Bus 6/17/19
IDK why, but this song is deeply imbedded in my psyche in such a way that it will spontaneously get stuck in my head when I haven’t heard it for months.
//BNJMN (6/17/19): I didn’t get carded at one of those places with a sign that says they’ll card anyone who looks like they are under 40 and now I’m concerned.