Miles Zoltak
Miles Zoltak

Reputation: 221

Using Firebase Storage to render images on web homepage

I'm new to both web development and firebase storage. Usually if I were to make a website with publicly available images, I would just put that image URL into the src attribute of an <img> tag. And probably if I was using custom content on squarespace or something there would be a way to upload your images so that you could still just add the photo the same way? But since I'm using firebase hosting I thought I would use firebase storage to store my custom content.

So if I have a homepage that has images I want to display, is it effective to use Firebase Storage and just call the getDownloadURL method to get a url that I can then inject into my HTML via Javascript?

I tried one instance of this, and it seems that the page pops up and then the download url came in after (unsurprisingly) but that just gave the whole thing a slow and laggy feel. Maybe it just feels that way because everything else was local on my machine so it popped up effortlessly, and it would look better when they're all being downloaded? But that seems kinda expensive in terms of network speed and usage, right?

Perhaps I'm just calling it in the wrong way (right now the script is referenced in <head> and that's how it's being rendered. Is there a best practice in terms of rendering content like this?

Upvotes: 0

Views: 541

Answers (1)

Tarik Huber
Tarik Huber

Reputation: 7418

If the images are dynamic you should use the firebase storage but if you mean static images of your side I don't see any benefit to use the storage. You can host the images directly with your JS code with the Firebase Hosting.

The hosting is also using the Google Global network to reduce the loading time of your side and with that also of your images.

Upvotes: 1

Related Questions