Top add

Locally Store image for faster uploads using HTML5

By storing my web page CSS, Javascript files or Images locally, I would have the added benefit of reduced network and server usage, in addition to improving page load times.  The HTML5 localStorage interface is a basic client-side key-value database, meaning data is saved and retrieved locally from the clients web browser storage.  However I hit an immediate challenge, as localStorage only supports String objects, and for my usage, I wanted to store binary Images.


Given this limitation in localStorage, the first step required for my implementation is to base64 encode the binary Images.   I found a website that offers an online tool to perform this encoding, however there are many shareware tools available to encode/decode binaries from your workstation or dynamically from a server application.  I converted my Images at OpinionatedGeek, which offers a simple web interface tool to quickly encode Images. Once you have base64 encoded your Images,  you will need to implement the Javascript and localStorage API to read & write your Images from the local client:

Javascript implementation:

<script>
  var hero;

  if ( localStorage.getItem('heroImg')) {
    hero = localStorage.getItem('heroImg');
  }
  else {
    hero = '/9j/4AAQSkZJRgABAgAAZABkAAD/7    /.../    6p+3dIR//9k=';
    localStorage.setItem('heroImg',hero);
  }

  document.getElementById("hero-graphic").src='data:image/png;base64,' + hero;
</script>


The corresponding HTML Image element:
<img id="hero-graphic" alt="Blog Hero Image" src="" />

1 comment:

DigitalHoper Technologies Faridabad said...

Best SEO Company in Faridabad - DigitalHoper Technologies provides Best SEO Company and SEO experts in Faridabad: As a top SEO agency, We offer the best SEO services in Faridabad to help all types of business. We are an SEO Company in Faridabad. We provide the best services in the field of Search Engine Optimization (SEO). At DigitalHoper Technologies, we deliver you Technical SEO Services that brings more traffic to your website. Our professional team of designers & developers offers you high-end designing for organic search engine optimization.

Established in 2010, DigitalHoper Technologies is a leading SEM Company in Faridabad. We help our clients grow their digital presence with high quality SEO services. We are renowned for our efficient and qualified work on all aspects of on-page Optimization, Off-page optimization, Content Marketing and Social media campaigns.

Since its establishment in 2010, DigitalHoper Technologies has been a leading SEO Company in Faridabad offering comprehensive SEM services for a variety of businesses. Our team of professional experts draws on years of experience to provide digital marketing solutions for both local and international clients.

DigitalHoper Technologies Offering SEM Services to the world wide clients, we are known for offering the best SEM services in the industry. Our SEM Company in Faridabad is a well-known SEO Firm having a team of experienced SEM experts. We take pride in serving the clients from the past 10 years. We have been designing search engine marketing strategies for increasing your traffic and increasing brand recognition.

At DigitalHoper Technologies, we provide excellent search engine marketing services to our clients, along with search engine optimisation. The SEM Company in Faridabad helps you achieve high rankings through its complicated yet effective methods. Our SEM Experts are highly proficient in various search engine optimisation techniques to meet client needs.

At SEM Company in Faridabad, DigitalHoper Technologies offers SEM services that are unparalleled in the industry. Our SEM Company in Faridabad delivers results that match your goals, and our campaigns are developed to make sure you receive the best return on investment.

Our company specializes in search engine optimization campaigns on platforms like Google, Yahoo, Bing, etc. For media services, we handle all kinds of media placements - Google ads, Facebook ads, digital advertisement, or digital print ads. If you are looking for an exceptional SEO Company in Faridabad, DigitalHoper Technologies is the only destination for your search.

DigitalHoper Technologies is your one-stop-shop for all your internet marketing needs. Our SEO Company in Faridabad helps build, grow, streamline and track your digital marketing programs.

Established in the year 2010, we have come a long way since then and today we stand as one of the most revered Search Engine Optimization (SEO) Company in Faridabad region. The Best SEO Company in Faridabad that you need for Search Engine Optimization jobs is now at your service, ready to work for you with tireless dedication and a passion that cannot be quelled with DigitalHoper Technologies.

Visit:
https://www.digitalhoper.com/seo-company-in-faridabad/

https://www.digitalhoper.com/digital-marketing-company-in-faridabad/

https://www.digitalhoper.com/website-designing-company-in-faridabad/