473,387 Members | 1,515 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

What are ways to make web app loads faster and avoid lags?

In my application, as a newbie, there are lots of images i used which is bigger isize which makes apps to laggy and difficult. Does any what are the ways in optimizing images and make thejavascript run smoothly?

Thanks
Jan 24 '20 #1
3 3016
gits
5,390 Expert Mod 4TB
basically its not an issue with JavaScript if your images are too big. Optimize them and it will be already better. Of course it might be that the JavaScript code can be optimized as well - but for that we would need to see that code here.
Jan 24 '20 #2
rollerbladegirl
69 64KB
One of the ways to do this might be to change the "depth" of the images.

Depth............................bit
(2) colors....................is (1) bit
(16) colors..................is (4) bit
(256) colors................is (8) bit
(32k) colors................is (15) bit
(64k) colors................is (16) bit
(16 Million) colors.......is (24) bit


If you know how to resize images in your JavaScript, then another way might be to make your images resized to the size that you want to be seen; starting with smaller images which when resized larger do not lose too much of the clarity that you want. Thus potentially less transmission to be lagged.

Example: If you want a 300 x 300 image to be seen, then make a smaller image, maybe 250 x 250 and resize it to 300 x 300 with your JavaScript and see how it looks. If it looks nice then try smaller like maybe 225 x 225 and resize that and see how it looks. Depending on your level of understanding JavaScript, you might get this to work. It could take a lot of time for this if each image is sufficiently different and if you want to make each image resize larger and keep sufficient clarity for that particular image.

You mentioned "lags." Many supposed experts have said that you should load all of your images first then show them, and other stuff like that. If your user has to wait on transmission lag, then you might be dealing with other than your image size. A user that has to wait and wait and wait while some silly JavaScript thing is circling around and around might get tired of waiting. The user might be better served by showing all of the text of the web page, and the forms, etc., while putting empty boxes where the images are to (when transmitted) be placed. It might not look so fancy for the user, but they might be less likely to get irritated with "you" and "your" website. They might accept that the "transmission" that they are using could be the difficulty and thus have less negativity toward your web page.

As a direct example:
I have a very fast internet connection. If a page takes more than about 10 to 15 seconds to load sufficiently for me to interact with it, then I might close the page. That is right. I hit the "X" and close that page. If it happens more than a few times and I remember that site, occasionally I have put such a web site in my page file and block the site completely. If JavaScript takes too long to load, and it does that multiple times, I might put that web site in my page file also. If the web site owner does not fix the problem on their end, then they might not get to show their entire site to me. I do not tolerate idiots and flippancy often. As an aside, I go to lots of sites and on them I see "Unable to connect" boxes. Ok, they had their chance. Try not to irritate your customers (if you are in business). Make your page show up quickly, then if you want images put a placeholder for them and your customer might be tolerant and wait for them.


Links to JavaScript resizing:

Reducing the upload sie by resizing image on the client side with JQuery [https://dejanstojanovic.net/javascri...-with-jquery/]

Resize in general with JavaScript [https://zocada.com/compress-resize-i...ript-browser/]

Here is another one [https://gist.github.com/MikeRogers0/6264546]

Far more there than I feel like typing this time. If you do not understand them, then I suggest reading each page completely with all comments and not just scanning the page and grabbing the code as some might do.

In commercial use, it might be far more important that the negative response by the user is diminished, rather than making it easier for you producing the effect.

.
Jan 28 '20 #3
I agree with the above responses.
Simply compress the images through services like https://tinypng.com/.
Mar 10 '20 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Wolfgang Keller | last post by:
Hello, as a non-developer I am currently participating in an industrial "research" project to develop a so-called "web application". This application serves at the same time as middleware to...
1
by: Brent Patroch | last post by:
Hello, Novice here, I am doing bulk emails using CDO, connection to a smtp server at another location. I am trying to streamline my script, or through it out and start over to make it faster. ...
19
by: pkilambi | last post by:
I wrote this function which does the following: after readling lines from file.It splits and finds the word occurences through a hash table...for some reason this is quite slow..can some one...
43
by: Mountain Bikn' Guy | last post by:
I have a situation where an app writes data of various types (primitives and objects) into a single dimensional array of objects. (This array eventually becomes a row in a data table, but that's...
3
by: Darren Clark | last post by:
Is there a difference in performance betwen these 2 styles of code? As it both does the same thing... if (row.ToString() == "1") this.Visa.Text = "Yes"; else this.Visa.Text = "No"; verses
10
by: Extremest | last post by:
I know there are ways to make this a lot faster. Any newsreader does this in seconds. I don't know how they do it and I am very new to c#. If anyone knows a faster way please let me know. All...
13
by: Simply_Red | last post by:
Hi, is there a way to make this function faster??? struct Points { double X; double Y; };
48
by: istillshine | last post by:
When I used gprof to see which function consumed most running time, I identified the following one. sz was less than 5000 on average, but foo had been called about 1,000,000 times. I have tried...
1
by: Carlos2013 | last post by:
I ask for your help: I have an invoice that contains four types of numbers and letters, example: ID Attorney Suc Nș Fact letter 20-12345678-9 0001 00000012- A What I need is to avoid...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.