Resize your images client-side with svelte.js

Resize your images client-side with svelte.js

So, you have started your next big project, it has a feature to allow users to upload pictures, your team agreed to call it Ultragram You have started your next big project, it has a feature to allow users to upload pictures, your team agreed to call it Ultragram (You can judge my lack of creativity later). Ultragram is great, you’ve got users, and everyone is happy.

You have started your next big project, it has a feature to allow users to upload pictures, your team agreed to call it Ultragram (You can judge my lack of creativity later).

Ultragram is great, you’ve got users, and everyone is happy.

Then all of a sudden, you get angry performance reviews from your users, you quickly realize that the internet speed of your users isn’t as great as yours, with your fancy office setup, the app’s performance is slow, loading time seems endless, and after investigation, the culprit is found, very large images uploaded by your users, from their brand new state of the art High definition iPhones.

What if you could save storage space, bandwidth, and improve the overall performance of the app? It turns out you can! by compressing image files client-side. Remember that smaller file sizes also mean smaller bills from your cloud provider.

Uploaded files will be chewed by your client app, and the compressed version will be sent to the server.

Let’s do this!

Create A Svelte App

First of all, let’s create a svelte app.

npx degit sveltejs/template ultragram
cd ultragram && yarn

#Or if you are using npm
npx degit sveltejs/template ultragram
cd ultragram && npm install

Dependencies

We’re going to use an amazing npm package that uses the canvas to resize your images client-side, it was named… hold on to your hats…, react-image-file-resizer!. And yeah, I know it’s weird too, but it works! We’re going to use it with svelte.

Install it with the following command:

yarn add react-image-file-resizer axios

#Or if you are using npm
npm add react-image-file-resizer axios

We’re going to need axios for POST requests.

If you are using the svelte REPL to follow along, you might experience some weird behavior once you import the package, I’ll recommend using your local environment with VSCode, Atom, or whatever editor works for you.


svelte sveltejs front-end-development javascript compression

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

5 Reasons Why You Should Use Svelte for Front End Development in 2021

Svelte is a front-end JavaScript framework, I’m going to be talking about 5 reasons why Svelte is the best JavaScript framework: Performance, Bundle size, Popularity, Lines of code, Developer Experience

Top 6 Productivity Tools for Front-end Developers

Today I wanted to share with you the tools I daily use to increase my productivity as a front-end developer. 6 tools to increase your productivity as a Front-end developer.

5 JavaScript Projects You Should Build As a Front-End Developer

5 JavaScript Projects You Should Build As a Front-End Developer: Brochure website; A blog template with HTML and CSS; Web application using an API; An eCommerce shopping cart; Personal portfolio

Hire Front End Developer | Hire Dedicated Front End Programmers In India

Hire Front-end web developers and programmers in India from ValueCoders for your custom offshore Front-end application development projects. Hire Front-end developer from ValueCoders and get interactive Front-end web designs. 16+ years exp. , 100% money back guarantee, 450+ Staff . Contact Us Today!

8 Performance Analysis Tools for Front-End Development

8 Performance Analysis Tools for Front-End Development. Recommended tools to test and analyze your frontend code performance.